Skip to content

Fix Windows non-blocking HTTP connections and port check warnings - #910

Open
rolling-code wants to merge 5 commits into
sullo:mainfrom
rolling-code:fix-windows-nonblocking-connect
Open

Fix Windows non-blocking HTTP connections and port check warnings#910
rolling-code wants to merge 5 commits into
sullo:mainfrom
rolling-code:fix-windows-nonblocking-connect

Conversation

@rolling-code

Copy link
Copy Markdown

Summary

Fix two related connection-handling issues observed with Nikto 2.6.1 on
Windows using Strawberry Perl 5.42.2.

Problems

Nonnumeric port-check result

port_check() returns 1 for HTTP, 2 for HTTPS, or a descriptive error
string. The caller compared the result numerically, causing warnings such as:

Argument "Unable to connect..." isn't numeric in numeric ne (!=)

The success values are now compared as strings.

Windows non-blocking connection

On Windows, a pending non-blocking Winsock connection reports
WSAEWOULDBLOCK through Perl's native extended error variable $^E.

LW2 checked only $!, causing a normal connection-in-progress state to be
treated as a fatal connection error.

The updated connection path:

  • Checks both Perl errno and the native Windows extended error
  • Recognizes EINPROGRESS and EWOULDBLOCK
  • Waits for socket writability using select()
  • Confirms completion with getpeername()
  • Uses separate writable and exception bit vectors

Environment

  • Windows 11
  • Strawberry Perl 5.42.2.1
  • Nikto 2.6.1
  • Upstream base commit: d5067406bc0902f8174cb5f8d595f637951974ce

Validation

Successful validation:

  • perl -c program/nikto.pl
  • HTTP request by hostname
  • HTTP request by direct IPv4 address with virtual host
  • HTTPS request by hostname
  • Closed localhost port failure
  • perl program/nikto.pl -dbcheck
  • git diff --check

A closed local port still fails cleanly without a numeric warning.

@rolling-code

Copy link
Copy Markdown
Author

looks good

@rolling-code rolling-code left a comment

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice

@sullo

sullo commented Aug 11, 2026

Copy link
Copy Markdown
Owner

I had a chance to check this out and it looks good. I will get a pre-release branch set up shortly and merge this into it. I'm working a little on my processes to avoid breaking main while doing releases more frequently.

@rolling-code rolling-code left a comment

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

beautiful

@rolling-code rolling-code left a comment

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lotus...I'm old enough to remember :-(

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants