Commit graph

424 commits

Author SHA1 Message Date
dmiller
082894dcad Try to loosen OpenSSL security. Fixes #583
Some checks are pending
nmap multiplatform autobuilds / build (arm64, gcc, ubuntu-latest-gcc-arm64, ubuntu-latest) (push) Waiting to run
nmap multiplatform autobuilds / build (clang, freebsd-15-clang, ubuntu-latest) (push) Waiting to run
nmap multiplatform autobuilds / build (clang, macos-15-clang, macos-15) (push) Waiting to run
nmap multiplatform autobuilds / build (clang, macos-26-clang, macos-26) (push) Waiting to run
nmap multiplatform autobuilds / build (clang, netbsd-10-clang, ubuntu-latest) (push) Waiting to run
nmap multiplatform autobuilds / build (clang, openbsd-7-clang, ubuntu-latest) (push) Waiting to run
nmap multiplatform autobuilds / build (clang, solaris-11-clang, ubuntu-latest) (push) Waiting to run
nmap multiplatform autobuilds / build (clang, ubuntu-latest-clang, ubuntu-latest) (push) Waiting to run
nmap multiplatform autobuilds / build (egcc, openbsd-7-gcc, ubuntu-latest) (push) Waiting to run
nmap multiplatform autobuilds / build (gcc, freebsd-15-gcc, ubuntu-latest) (push) Waiting to run
nmap multiplatform autobuilds / build (gcc, netbsd-10-gcc, ubuntu-latest) (push) Waiting to run
nmap multiplatform autobuilds / build (gcc, solaris-11-gcc, ubuntu-latest) (push) Waiting to run
nmap multiplatform autobuilds / build (gcc, ubuntu-latest-gcc, ubuntu-latest) (push) Waiting to run
nmap multiplatform autobuilds / build (msvc, windows-latest-msvc, windows-latest) (push) Waiting to run
2026-05-12 21:53:50 +00:00
dmiller
c03bdbcc18 Use unsigned lengths to match libpcap 2026-04-30 22:01:59 +00:00
dmiller
7baee8efa9 Avoid leaking pending events in nsock_pool_delete 2026-04-15 03:21:56 +00:00
dmiller
209da5174d Track and unload OpenSSL providers 2026-04-06 21:33:44 +00:00
dmiller
c693c60a54 Fix leak of canceled events 2026-04-06 21:33:44 +00:00
dmiller
61f7a8d3ca Fix memory leak in proxychain parsing 2026-04-06 21:33:43 +00:00
dmiller
deb076224e Reintegrate Nmap 7.99 release branch 2026-03-27 13:52:02 +00:00
dmiller
25a76d7876 Fix compilation with OpenSSL 1.0.1 2026-02-25 20:43:12 +00:00
dmiller
a16b2848ef fix c99-ism in nsock test 2026-02-25 20:41:19 +00:00
dmiller
95d380b836 Bump copyright date to 2026 [skip ci] 2026-02-16 22:33:40 +00:00
dmiller
02b7df4d83 Fix build for OpenSSL <3.0 2026-02-16 19:47:13 +00:00
dmiller
f87c5e20b2 SSL data read before error results in successful read. 2026-02-11 22:27:51 +00:00
dmiller
1b3ca45054 Compatibility fixes and Github autobuilds. Closes #3214 2026-01-12 16:59:25 +00:00
dmiller
58874849d3 Reintegrate Nmap 7.98 release branch 2025-08-21 20:24:37 +00:00
dmiller
e048a3e91d Fix incorrect assertions in Nsock poll engine 2025-08-09 02:52:55 +00:00
dmiller
f2028a2007 Nsock poll engine: notice HUP/ERR/NVAL on Windows. See #3138? 2025-06-25 00:47:44 +00:00
dmiller
40b5bda3ac Consistent Windows build parameters 2025-04-15 23:58:46 +00:00
dmiller
5b52e7a3f2 Build fixes 2025-04-10 19:24:22 +00:00
dmiller
5f6bc69983 Account for VLAN header in pcap packets if needed. 2025-04-10 19:00:50 +00:00
dmiller
6db5c9cb85 Bump copyright date 2025-02-26 17:44:43 +00:00
dmiller
4f712b76a3 Avoid printing (null):-1 for STDIN in Nsock debug output 2024-12-09 20:03:48 +00:00
dmiller
8bb1334a87 Avoid printing junk timeouts in Nsock debug output 2024-12-06 20:44:28 +00:00
dmiller
92d5b6a310 Correctly process satisfied request from pending SSL data 2024-11-25 22:09:08 +00:00
dmiller
1264a6e472 Increment first, then decrement; avoid clearing desired bit 2024-11-25 22:09:07 +00:00
dmiller
3a0db5dc51 Try an SSL_read() immediately to get the correct ssl_desire 2024-11-21 20:11:38 +00:00
dmiller
38823b5cd1 Handle SSL_read()/SSL_write() returning 0 when not EOF.
OpenSSL docs say, "Old documentation indicated a difference between 0
and -1, and that -1 was retryable. You should instead call
SSL_get_error() to find out if it's retryable."
2024-11-21 20:11:38 +00:00
dmiller
ff1df7a80c Zero IOD in nsock_iod_new2. Was reusing old peer info 2024-11-18 23:02:48 +00:00
dmiller
4efe456e0b Nsock iocp: pass immediate errors on to process_event() 2024-11-18 21:19:46 +00:00
dmiller
b1f6f9b088 Track EOF at IOD level also 2024-11-18 20:26:28 +00:00
dmiller
1f6e8d9fe3 Handle EWOULDBLOCK as well as EAGAIN 2024-11-18 20:26:27 +00:00
dmiller
cffc94e845 Consolidate event list management to nevent_unref()
Removes duplicate logic for PCAP_BSD_SELECT_HACK. May address accounting
problems that led to issues like #187 (macOS) and #2912 (Windows).
2024-11-13 19:15:12 +00:00
dmiller
222add87a6 Paranoid gh_list check: node is in list before removal 2024-11-13 19:15:11 +00:00
dmiller
3f64103cf0 Move some prototypes to nsock_internal.h 2024-11-13 19:15:10 +00:00
dmiller
379b56b582 Include timeout info in debug output for all nsock reads/connects 2024-11-12 20:05:56 +00:00
dmiller
1e8c1ab3cd Let all nsock engines use STDIN on Windows! 2024-11-06 16:48:29 +00:00
dmiller
635cc50011 Nsock iocp: fix IPv6 connect 2024-11-06 16:06:32 +00:00
dmiller
411b186576 Simplify nevent_delete for PCAP_BSD_SELECT_HACK mode 2024-11-01 18:40:09 +00:00
dmiller
2ca95ad6b4 Nsock select engine: don't process if sd is -1 (nonselectable) 2024-11-01 18:40:08 +00:00
dmiller
931c13cd21 Fixes for IOCP engine build 2024-10-15 20:37:11 +00:00
dmiller
7703b045e5 Nsock poll engine: efficient use of pollfds array
Using socket descriptor as an index works okay for UNIX, though it
wastes the first several indices which are assigned to STDIN/STDOUT,
files, etc. However, for Windows it is really bad, since descriptors are
large, nonconsecutive numbers. Using a little overhead to track each
iod's index and the next empty space is worth it.
2024-10-11 20:59:35 +00:00
dmiller
b94ae785ba Fix handling of non-select()-able pcap handles
1. pcap_get_selectable_fd() may return -1 for some devices, even if the
   platform as a whole supports select() on these handles. Check for
   this condition throughout.
2. The various backend system calls (kevent, poll, epoll, etc.) do not
   sleep for the timeout period if no valid handles are registered,
   unlike select on UNIX. This leads to busy wait, looping continuously.
   Instead, we call usleep() in those cases.
2024-10-11 20:59:34 +00:00
dmiller
6186767cd1 Move a useful function to nsock_core.c 2024-10-11 20:59:33 +00:00
dmiller
532938f49c Do a non-blocking check for events when pcap data is available
For platforms without selectable pcap handles (e.g. Windows), the
arrival of data for a pcap read would previously skip checking for any
triggered non-pcap events in that loop iteration. This is not usually a
problem because the next loop will be triggered immediately, picking up
the non-pcap events before any further pcap data arrives. However,
excessive pcap data on a handle in immediate mode might prevent the
engine loop from checking for non-pcap events for long enough to result
in timeouts. Instead, do a non-blocking check for triggered events in
this case and handle those in the same loop iteration.
2024-10-09 17:40:10 +00:00
dmiller
167fafe65c Correctly handle all cases for canceling IO in iocp engine 2024-10-08 21:14:43 +00:00
dmiller
f765af4070 IOCP engine: further checks against duplicating eovs 2024-10-08 21:14:42 +00:00
dmiller
30bc184e0f Fix iocp engine when calling nsock_read on unconnected socket
When the IOD isn't connected, iod->peerlen is 0, which means WSARecvFrom
returns WSAEFAULT because the lpFrom parameter is not NULL, and 0 bytes
is not enough space to fit any sockaddr.
2024-10-08 21:14:42 +00:00
dmiller
d42dd7eed9 Additional tests and checks for gh_heap validity 2024-10-08 21:14:41 +00:00
dmiller
cb483ec503 Properly handle SSL connect events. Fixes #2139
SSL_WANT_READ and SSL_WANT_WRITE conditions modify the watched events during
NSE_TYPE_CONNECT_SSL, which was causing the IOCP engine to re-post the same
completion packet multiple times. Adding a status field to the
extended_overlapped struct resolves this.

Additionally, canceled and timed-out events risked the same extended_overlapped
being freed multiple times, which caused the gh_heap corruption in the original
issue report.
2024-10-07 18:30:28 +00:00
dmiller
a86e86913b Ensure events are updated if SSL connect times out 2024-10-06 22:19:30 +00:00
dmiller
dde9c509ed Allow nsock_iod_get_communication_info() to get latest UDP peer 2024-07-01 16:17:42 +00:00