From aea57f78497728382115de17d3d2aae1473f7c57 Mon Sep 17 00:00:00 2001 From: dmiller Date: Thu, 5 Mar 2026 20:16:22 +0000 Subject: [PATCH] Fix HTTP proxy SSL mode --- ncat/http.c | 6 +++--- ncat/ncat_proxy.c | 7 ++++--- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/ncat/http.c b/ncat/http.c index a13c83d92..632db0207 100644 --- a/ncat/http.c +++ b/ncat/http.c @@ -92,7 +92,7 @@ int socket_buffer_read(struct socket_buffer *buf, char *out, size_t size) do { errno = 0; i = fdinfo_recv(&buf->fdn, buf->buffer, sizeof(buf->buffer)); - } while (i == -1 && errno == EINTR); + } while (i == -1 && buf->fdn.lasterr == EINTR); if (i <= 0) return i; buf->end = buf->buffer + i; @@ -130,7 +130,7 @@ char *socket_buffer_readline(struct socket_buffer *buf, size_t *n, size_t maxlen do { errno = 0; i = fdinfo_recv(&buf->fdn, buf->buffer, sizeof(buf->buffer)); - } while (i == -1 && errno == EINTR); + } while (i == -1 && buf->fdn.lasterr == EINTR); if (i <= 0) { free(line); return NULL; @@ -177,7 +177,7 @@ int socket_buffer_readcount(struct socket_buffer *buf, char *out, size_t size) do { errno = 0; i = fdinfo_recv(&buf->fdn, buf->buffer, sizeof(buf->buffer)); - } while (i == -1 && errno == EINTR); + } while (i == -1 && buf->fdn.lasterr == EINTR); if (i <= 0) return -1; buf->end = buf->buffer + i; diff --git a/ncat/ncat_proxy.c b/ncat/ncat_proxy.c index 93d8b0606..e58f785ca 100644 --- a/ncat/ncat_proxy.c +++ b/ncat/ncat_proxy.c @@ -296,6 +296,8 @@ static void http_server_handler(int c) char *buf; socket_buffer_init(&sock, c); + block_socket(sock.fdn.fd); + #if HAVE_OPENSSL if (o.ssl) { sock.fdn.ssl = new_ssl(sock.fdn.fd); @@ -307,7 +309,6 @@ static void http_server_handler(int c) } } #endif - block_socket(sock.fdn.fd); code = http_read_request_line(&sock, &buf); if (code != 0) { @@ -478,7 +479,7 @@ static int handle_connect(struct socket_buffer *client_sock, do { do { len = fdinfo_recv(&client_sock->fdn, buf, sizeof(buf)); - } while (len == -1 && socket_errno() == EINTR); + } while (len == -1 && client_sock->fdn.lasterr == EINTR); if (len <= 0) goto end; @@ -499,7 +500,7 @@ static int handle_connect(struct socket_buffer *client_sock, do { rc = fdinfo_send(&client_sock->fdn, buf, len); - } while (rc == -1 && socket_errno() == EINTR); + } while (rc == -1 && client_sock->fdn.lasterr == EINTR); if (rc == -1) goto end; }