summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorReyk Floeter <reyk@cvs.openbsd.org>2008-08-08 19:13:25 +0000
committerReyk Floeter <reyk@cvs.openbsd.org>2008-08-08 19:13:25 +0000
commit0803d5d26e2dd17745f1b26c5c7b29a000594113 (patch)
tree4e4eb68de05812f114f9e4a12a31553f834329c4
parent4b0c33f66b217832f1ba35389eb2a525321017d7 (diff)
fix possible memleaks in chunked encoding handler
-rw-r--r--usr.sbin/relayd/relay.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/usr.sbin/relayd/relay.c b/usr.sbin/relayd/relay.c
index 9796f92011b..8f47023f508 100644
--- a/usr.sbin/relayd/relay.c
+++ b/usr.sbin/relayd/relay.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: relay.c,v 1.98 2008/08/08 18:56:05 reyk Exp $ */
+/* $OpenBSD: relay.c,v 1.99 2008/08/08 19:13:24 reyk Exp $ */
/*
* Copyright (c) 2006, 2007, 2008 Reyk Floeter <reyk@openbsd.org>
@@ -1191,8 +1191,10 @@ relay_read_httpchunks(struct bufferevent *bev, void *arg)
relay_close(con, "invalid chunk");
return;
}
- if (!strlen(line))
+ if (!strlen(line)) {
+ free(line);
goto next;
+ }
/* Read prepended chunk size in hex, ingore the trailer */
if (sscanf(line, "%lx", &lval) != 1) {
@@ -1202,8 +1204,10 @@ relay_read_httpchunks(struct bufferevent *bev, void *arg)
}
if (relay_bufferevent_print(cre->dst, line) == -1 ||
- relay_bufferevent_print(cre->dst, "\r\n") == -1)
+ relay_bufferevent_print(cre->dst, "\r\n") == -1) {
+ free(line);
goto fail;
+ }
free(line);
/* Last chunk is 0 bytes followed by an empty newline */