Skip to content

Commit

Permalink
[proto_ws] fix mem leak when hdr parsing fails
Browse files Browse the repository at this point in the history
Even if the hdr parsing failed (due to a bogus hdr), you still have to free whatever hdrs were already parsed ;)
Reported by @11qeq11
Closes #3353
bogdan-iancu committed Apr 24, 2024
1 parent 09a7eaf commit 6a84736
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions modules/proto_ws/ws_handshake_common.h
Original file line number Diff line number Diff line change
@@ -846,7 +846,7 @@ static int ws_parse_req_handshake(struct tcp_connection *c, char *msg, int len)
tmp_msg.buf = tmp_msg.unparsed = msg;
if (parse_headers_aux(&tmp_msg, HDR_EOH_F, 0,0) < 0) {
LM_ERR("cannot parse headers\n%.*s\n", len, msg);
goto error;
goto ws_error;
}
/* verify headers according to RFC6455 */
for (hf = tmp_msg.headers; hf; hf = hf->next) {
@@ -1124,7 +1124,7 @@ static int ws_parse_rpl_handshake(struct tcp_connection *c, char *msg, int len)
tmp_msg.buf = tmp_msg.unparsed = msg;
if (parse_headers_aux(&tmp_msg, HDR_EOH_F, 0, 0) < 0) {
LM_ERR("cannot parse headers\n%.*s\n", len, msg);
goto error;
goto ws_error;
}
/* verify headers according to RFC6455 */
for (hf = tmp_msg.headers; hf; hf = hf->next) {

0 comments on commit 6a84736

Please sign in to comment.