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

(cherry picked from commit 6a84736)
  • Loading branch information
bogdan-iancu committed Apr 24, 2024
1 parent e650695 commit 702812f
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
Expand Up @@ -838,7 +838,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(&tmp_msg, HDR_EOH_F, 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) {
Expand Down Expand Up @@ -1116,7 +1116,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(&tmp_msg, HDR_EOH_F, 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) {
Expand Down

0 comments on commit 702812f

Please sign in to comment.