1
0
mirror of https://github.com/nmap/nmap.git synced 2025-12-30 11:29:01 +00:00
Commit Graph

224 Commits

Author SHA1 Message Date
dmiller
f66eadbcd2 Fix typo of nsock_loglevel_t enum value (broke build on VS2013) 2015-06-30 19:49:07 +00:00
henri
ea495ddecd Cosmetic fixes
Removed unneeded NULL-checks before free()
Flattened code structures
2015-06-27 08:21:56 +00:00
henri
b55ff2d68f Don't associate nsock logging info to a nspool.
Make current loglevel and current log callback global
to the library. Attaching them to the nsock pool doesn't
bring any benefit and prevents from logging activity in
code sections that don't have access to a pool (such as
proxy chain specification parsing).

Updated external calls and nsock tests accordingly.
2015-06-27 08:21:53 +00:00
henri
b75233ce98 Consistently renamed nsi_XXX calls into nsock_iod_XXX
This is part of the effort to make nsock expose only
nsock_ prefixed symbols and simplify the API.
2015-06-27 08:21:33 +00:00
henri
fd40b8df08 Simplify Nsock SSL init API
Replaced nsock_pool_ssl_init_max_speed() by a NSOCK_SSL_MAX_SPEED
flag to be passed to nsock_pool_ssl_init(). Default (flag=0) means
secure.
2015-06-27 08:21:22 +00:00
henri
0348359f60 Enforce nsock naming scheme.
convert nsp_* calls into nsock_pool_*. Separate words with underscores
where appropriate.
2015-06-27 08:21:16 +00:00
henri
ab161bbb0b Remove nsock_pool unique identifiers.
This isn't used anywhere and I cannot think of any use case.
The NSP is supposed to be unique and global as it controls the
event loop.
2015-06-27 08:21:05 +00:00
dmiller
68409b2226 Update copyright date to 2015 2015-06-03 13:01:29 +00:00
henri
d7a3d43eb6 Reduce CPU consumption with nsock engine poll
Entering nsock_loop() with the poll engine activated and no registered FD
(timers only, for instance) should not directly return, but sleep until next
timeout.
2015-02-21 21:15:21 +00:00
henri
7b02dea019 Remove dead code: einfo->evlen cannot be zero. 2015-02-21 21:15:15 +00:00
dmiller
fc99bed706 Don't use unnecessary parens with __declspec
Reported by nnposter, this broke on VS2010. Pretty sure this was just a
simple mistake in the first place. Fixes #33
2015-01-01 13:39:47 +00:00
dmiller
f6d70cd3e6 Revert r33815 (unrelated changes) 2014-11-17 13:31:56 +00:00
dmiller
2b9fade75b Fix Nsock's make check: wrong value tested 2014-11-17 13:25:35 +00:00
dmiller
85bb2d388d Define a NORETURN macro 2014-11-17 13:25:32 +00:00
dmiller
a067bc25bc Let MSVC know about noreturn attribute to help with code analysis 2014-11-12 13:29:40 +00:00
dmiller
7797826e5d Silence a compiler warning on VS2013: not all code paths return a value 2014-11-11 06:06:46 +00:00
dmiller
80f18a2bc7 Add configure test for PCAP_NETMASK_UNKNOWN 2014-10-31 13:28:12 +00:00
fyodor
f6f59a7cd7 Auto regeneration with latest template files, etc. 2014-08-13 22:57:43 +00:00
henri
b5a6d20a6e Fail early when unable to properly resolve proxy names.
Some errors were not properly propagated. Ensure proxy_resolve() returns
a negative error code and make the caller fatal() when unable to complete
proxy_chain initialization for whatever reason.
2014-07-08 17:50:51 +00:00
dmiller
ec9074f718 Correct "it's" to "its" where necessary
it's = it is
its = belonging to it
2014-06-19 04:58:46 +00:00
henri
ccf6e15b90 Nsock early error reporting.
Report finished (likely failed) events as early as possible. Because the
corresponding IODs can have no I/O activity, they wouldn't be flagged as active
by the I/O engines and the events could end up being delivered at shutdown only
(or never).

Reported by d33tah on http://seclists.org/nmap-dev/2014/q2/409
2014-06-11 20:14:16 +00:00
henri
d13dab54c3 Replaced internal opaque types by structs. 2014-05-21 19:59:42 +00:00
henri
687d153378 Divide code cleanly between ssl and non-ssl versions 2014-05-21 19:59:29 +00:00
dmiller
573f9c1a73 Fix a libpcap dependency flag in nsock test suite 2014-03-14 22:08:51 +00:00
dmiller
3f0d0c16f9 Spellcheck on Nmap, Nsock, Nbase source files 2014-02-20 18:44:12 +00:00
dmiller
c9714990c7 Remove trailing whitespace from C/C++ files
https://secwiki.org/w/Nmap/Code_Standards
2014-02-12 20:25:51 +00:00
henri
d5746993e2 Define nsi_delete() notify modes as enums.
These values aren't flags that can be ORed.
2014-02-03 20:53:09 +00:00
henri
64fb5b3482 Added safe fd_set operations.
Only FD_SET and FD_CLR were available. Added a FD_ISSET equivalent.
Implemented them as static inline instead of macros for consistency.

These functions abort() if the FD number is higher than FD_SETSIZE
(except on windows where no check is performed).
2014-01-30 19:02:57 +00:00
dmiller
83fd814a2c Really fix nsock's pcap configuration
This wasn't using Nmap's included libpcap if no options were specified,
instead compiling nsock without pcap support if no libpcap could be
found (which breaks Nmap)
2014-01-30 03:40:26 +00:00
dmiller
16505b5cc7 Nsock: let libpcap decisions set LDFLAGS, needed for make check 2014-01-26 16:38:24 +00:00
dmiller
2e047114f6 Improve support for non-included libpcap in nsock 2014-01-26 16:38:22 +00:00
dmiller
6251f85c9e Let nsock handle --with-libpcap in the same way as Nmap 2014-01-26 16:38:18 +00:00
henri
0ba3dc0be7 Include stddef only if required 2013-12-30 14:35:50 +00:00
d33tah
c7927c5449 Add missing stddef.h import. 2013-12-30 13:58:46 +00:00
dmiller
2506269bcc Let nsock's configure take the same --with-libpcap as Nmap does 2013-12-11 23:17:50 +00:00
dmiller
26b471c923 Also clean the tests dir when doing make clean (nsock) 2013-12-02 21:36:41 +00:00
dmiller
80510e96d6 Properly remove nsock_config.h on make distclean 2013-12-02 21:15:25 +00:00
dmiller
e4ce527a38 Avoid null pointer dereference to implement container_of
Using offsetof instead of actually dereferencing a 0 pointer is still
standards compliant (works under gcc -ansi, clang -ansi), and is more in
line with how Linux kernel defines this macro (kernel.h). Can't exactly
lift the kernel implementation because it uses gnu-extension typeof.

Not really a necessary change, but it was causing clang's address
sanitizer to complain.
2013-11-30 01:32:58 +00:00
dmiller
a5ce7f6083 Cast literal to appropriate type
On 64-bit, the literal 1 is a 32-bit integer, and can't be shifted
by the appropriate amount (61 bits).
2013-11-29 01:42:42 +00:00
henri
ba239a8610 Get rid of a level of indentation 2013-11-06 18:52:06 +00:00
henri
9c083de2cf Minor style fixes 2013-10-23 19:04:04 +00:00
david
d05d8acd93 Revert r32397, r32398, r32399 (tempnam to mkstemp).
I had intended the unlink to appy only to unix domain sockets, but it
was being called for every kind of local address.

http://seclists.org/nmap-dev/2013/q3/647
2013-09-27 15:30:18 +00:00
david
e18b25bccd Use tempfile in place of tempnam.
To avoid new GCC warnings about tempnam:
ncat_connect.c:789: warning: the use of `tempnam' is dangerous, better use `mkstemp'

Doing things this way has the same race condition as tempnam did,
because we are unlinking the file before binding it. (The race window is
smaller now.) The file must not exist before binding the Unix socket, or
else you get an "address already in use" error. Unlinking before binding
is the same thing that netcat-openbsd does. See this earlier thread:
http://seclists.org/nmap-dev/2012/q4/336.
2013-09-26 07:17:08 +00:00
henri
4fd3cc2f10 Allow NSE_TYPE_CONNECT_SSL to be canceled.
This fixes a really bad bug that seems to have been there for a while. Canceling
a nsock connect SSL operation fails with fatal(). I have never seen it in real
life though.

Added a corresponding unit test.
2013-09-15 10:52:07 +00:00
d33tah
4993befdb4 Fix a typo in nsock documentation. 2013-08-21 20:06:38 +00:00
henri
64c706c260 Proper code alignment. 2013-08-13 12:36:08 +00:00
d33tah
6805376faf Fix an nsock build error under MSVC. 2013-08-11 20:52:15 +00:00
henri
853aaff586 Manage expiration times via a heap queue.
This prevents nsock from iterating over the whole list of events at
each runloop, thus improving performance.

It made it necessary to have pointers from the msevents to the event
lists they belong to. The patch therefore also changes gh_list from
autonomous containers to embedded structures.

Added unit tests accordingly and cosmetic changes to make things look
more consistent.
2013-08-10 23:59:30 +00:00
henri
822d3e1da2 Fixed non-portable perror() statement.
Replaced perror() by printf + socket_strerror(socket_errno()).
Reported by Gisle Vanem.
2013-08-10 20:19:09 +00:00
henri
3a8607d65c Restore headers in nsock error.h
These includes seem useless and nsock and nmap happily compile w/o them but the
nsock test suite doesn't. Temporarily restore them to their pre-r36100 state
until I can clean and streamline the inclusion tree.
2013-08-06 19:39:39 +00:00