Skip to content

Commit 484e8d9

Browse files
author
fhajny
committed
Fix SSL queue handling based on an upstream patch. PKGREVISION++
bumptech/stud#130
1 parent a31ccdd commit 484e8d9

File tree

3 files changed

+40
-7
lines changed

3 files changed

+40
-7
lines changed

security/stud/Makefile

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
# $NetBSD: Makefile,v 1.3 2014/09/23 14:26:35 fhajny Exp $
1+
# $NetBSD: Makefile,v 1.4 2015/02/20 09:32:07 fhajny Exp $
22
#
33

44
PKGNAME= stud-0.3p53
5-
PKGREVISION= 2
5+
PKGREVISION= 3
66
CATEGORIES= security
77
MAINTAINER= jym@NetBSD.org
88
HOMEPAGE= http://github.com/bumptech/stud

security/stud/distinfo

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
$NetBSD: distinfo,v 1.1 2013/03/16 19:41:35 jym Exp $
1+
$NetBSD: distinfo,v 1.2 2015/02/20 09:32:07 fhajny Exp $
22

33
SHA1 (bumptech-stud-0.3-51-g0b88039.tar.gz) = fad22d9cf008b7db8f30d8d7ca0a6fcc177714de
44
RMD160 (bumptech-stud-0.3-51-g0b88039.tar.gz) = 66a186e1095fd127945802ab681f5948ee1d4011
55
Size (bumptech-stud-0.3-51-g0b88039.tar.gz) = 41000 bytes
66
SHA1 (patch-Makefile) = c0794c6ebb3bdc3d55b473acec674a9f98b03ffb
77
SHA1 (patch-configuration.c) = 886226a104f84bac6902bb8a8593d37a25653563
88
SHA1 (patch-stud.8) = a6b36ab6ac8c65cbc70172a9c230b22965cbdc3d
9-
SHA1 (patch-stud.c) = 9b11693619291925376f35f1443bbec83a1d798b
9+
SHA1 (patch-stud.c) = aae56a212de51dfec4c31a9f4318818a79a51dfd

security/stud/patches/patch-stud.c

+36-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1-
$NetBSD: patch-stud.c,v 1.1 2013/03/16 19:41:36 jym Exp $
1+
$NetBSD: patch-stud.c,v 1.2 2015/02/20 09:32:07 fhajny Exp $
22

33
SunOS fixes as per https://github.com/bumptech/stud/pull/71.
4-
--- stud.c.orig 2012-08-15 10:33:39.000000000 +0000
4+
SSL fixes as per https://github.com/bumptech/stud/pull/130.
5+
6+
--- stud.c.orig 2012-08-10 23:40:19.000000000 +0000
57
+++ stud.c
68
@@ -189,9 +189,17 @@ typedef struct proxystate {
79

@@ -35,7 +37,38 @@ SunOS fixes as per https://github.com/bumptech/stud/pull/71.
3537
if(setsockopt(fd, SOL_TCP, TCP_KEEPIDLE, &optval, optlen) < 0) {
3638
ERR("Error setting TCP_KEEPIDLE on client socket: %s", strerror(errno));
3739
}
38-
@@ -1751,24 +1759,16 @@ void daemonize () {
40+
@@ -889,6 +897,13 @@ static void shutdown_proxy(proxystate *p
41+
close(ps->fd_up);
42+
close(ps->fd_down);
43+
44+
+ // Clear the SSL error queue - it might contain details
45+
+ // of errors that we haven't consumed for whatever reason.
46+
+ // If we don't, future calls to SSL_get_error will lead to
47+
+ // weird/confusing results that can throw off the handling
48+
+ // of normal conditions like SSL_ERROR_WANT_READ.
49+
+ ERR_clear_error();
50+
+
51+
SSL_set_shutdown(ps->ssl, SSL_SENT_SHUTDOWN);
52+
SSL_free(ps->ssl);
53+
54+
@@ -1197,7 +1212,15 @@ static void client_handshake(struct ev_l
55+
shutdown_proxy(ps, SHUTDOWN_SSL);
56+
}
57+
else {
58+
- LOG("{%s} Unexpected SSL error (in handshake): %d\n", w->fd == ps->fd_up ? "client" : "backend", err);
59+
+
60+
+ // Try and get more detail on the error from the SSL
61+
+ // error queue. ERR_error_string requires a char buffer
62+
+ // of 120 bytes.
63+
+ unsigned long err_detail = ERR_get_error();
64+
+ char err_msg[120];
65+
+ ERR_error_string(err_detail, err_msg);
66+
+
67+
+ LOG("{client} Unexpected SSL error (in handshake): %d, %s\n", err, err_msg);
68+
shutdown_proxy(ps, SHUTDOWN_SSL);
69+
}
70+
}
71+
@@ -1751,24 +1774,16 @@ void daemonize () {
3972
exit(0);
4073
}
4174

0 commit comments

Comments
 (0)