diff options
author | Reyk Floeter <reyk@cvs.openbsd.org> | 2008-08-08 19:13:25 +0000 |
---|---|---|
committer | Reyk Floeter <reyk@cvs.openbsd.org> | 2008-08-08 19:13:25 +0000 |
commit | 0803d5d26e2dd17745f1b26c5c7b29a000594113 (patch) | |
tree | 4e4eb68de05812f114f9e4a12a31553f834329c4 | |
parent | 4b0c33f66b217832f1ba35389eb2a525321017d7 (diff) |
fix possible memleaks in chunked encoding handler
-rw-r--r-- | usr.sbin/relayd/relay.c | 10 |
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 */ |