ade1bcc810
non-blocking. Blocking can be considered a DOS problem because other requests are not served in that time. (SA44680, no CVE entry) bump PKGREV
83 lines
2.9 KiB
Text
83 lines
2.9 KiB
Text
$NetBSD: patch-ah,v 1.1 2011/05/25 09:29:05 drochner Exp $
|
|
|
|
--- src/http.c.orig 2009-08-07 14:23:33.000000000 +0000
|
|
+++ src/http.c
|
|
@@ -98,6 +98,16 @@ struct srventry
|
|
};
|
|
#endif/*!USE_DNS_SRV*/
|
|
|
|
+#ifdef HAVE_PTH
|
|
+# define my_select(a,b,c,d,e) pth_select ((a), (b), (c), (d), (e))
|
|
+# define my_connect(a,b,c) pth_connect ((a), (b), (c))
|
|
+# define my_accept(a,b,c) pth_accept ((a), (b), (c))
|
|
+#else
|
|
+# define my_select(a,b,c,d,e) select ((a), (b), (c), (d), (e))
|
|
+# define my_connect(a,b,c) connect ((a), (b), (c))
|
|
+# define my_accept(a,b,c) accept ((a), (b), (c))
|
|
+#endif
|
|
+
|
|
|
|
#ifdef HAVE_W32_SYSTEM
|
|
#define sock_close(a) closesocket(a)
|
|
@@ -1333,14 +1343,14 @@ start_server ()
|
|
FD_ZERO (&rfds);
|
|
FD_SET (fd, &rfds);
|
|
|
|
- if (select (fd + 1, &rfds, NULL, NULL, NULL) <= 0)
|
|
+ if (my_select (fd + 1, &rfds, NULL, NULL, NULL) <= 0)
|
|
continue; /* ignore any errors */
|
|
|
|
if (!FD_ISSET (fd, &rfds))
|
|
continue;
|
|
|
|
addrlen = sizeof peer;
|
|
- client = accept (fd, (struct sockaddr *) &peer, &addrlen);
|
|
+ client = my_accept (fd, (struct sockaddr *) &peer, &addrlen);
|
|
if (client == -1)
|
|
continue; /* oops */
|
|
|
|
@@ -1406,7 +1416,7 @@ connect_server (const char *server, unsi
|
|
addr.sin_port = htons(port);
|
|
memcpy (&addr.sin_addr,&inaddr,sizeof(inaddr));
|
|
|
|
- if (!connect (sock,(struct sockaddr *)&addr,sizeof(addr)) )
|
|
+ if (!my_connect (sock,(struct sockaddr *)&addr,sizeof(addr)) )
|
|
return sock;
|
|
sock_close(sock);
|
|
return -1;
|
|
@@ -1474,7 +1484,7 @@ connect_server (const char *server, unsi
|
|
return -1;
|
|
}
|
|
|
|
- if (connect (sock, ai->ai_addr, ai->ai_addrlen))
|
|
+ if (my_connect (sock, ai->ai_addr, ai->ai_addrlen))
|
|
last_errno = errno;
|
|
else
|
|
connected = 1;
|
|
@@ -1528,7 +1538,7 @@ connect_server (const char *server, unsi
|
|
for (i = 0; host->h_addr_list[i] && !connected; i++)
|
|
{
|
|
memcpy (&addr.sin_addr, host->h_addr_list[i], host->h_length);
|
|
- if (connect (sock, (struct sockaddr *) &addr, sizeof (addr)))
|
|
+ if (my_connect (sock, (struct sockaddr *) &addr, sizeof (addr)))
|
|
last_errno = errno;
|
|
else
|
|
{
|
|
@@ -1594,7 +1604,7 @@ cookie_read (void *cookie, void *buffer,
|
|
|
|
tv.tv_sec = 0;
|
|
tv.tv_usec = 50000;
|
|
- select (0, NULL, NULL, NULL, &tv);
|
|
+ my_select (0, NULL, NULL, NULL, &tv);
|
|
goto again;
|
|
}
|
|
if (nread == GNUTLS_E_REHANDSHAKE)
|
|
@@ -1649,7 +1659,7 @@ cookie_write (void *cookie, const void *
|
|
|
|
tv.tv_sec = 0;
|
|
tv.tv_usec = 50000;
|
|
- select (0, NULL, NULL, NULL, &tv);
|
|
+ my_select (0, NULL, NULL, NULL, &tv);
|
|
continue;
|
|
}
|
|
log_info ("TLS network write failed: %s\n",
|