From 57d539ef514b45fb37f83abe9894965fbc01ecc4 Mon Sep 17 00:00:00 2001 From: Lonny Wong Date: Wed, 22 Nov 2023 00:20:18 +0800 Subject: [PATCH] pmd: fix buffer being reused while draining extensions --- lib/roles/ws/ops-ws.c | 2 +- lib/roles/ws/private-lib-roles-ws.h | 1 + lib/roles/ws/server-ws.c | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/roles/ws/ops-ws.c b/lib/roles/ws/ops-ws.c index 37fbd34dcd..3898457a04 100644 --- a/lib/roles/ws/ops-ws.c +++ b/lib/roles/ws/ops-ws.c @@ -723,7 +723,7 @@ lws_ws_rx_sm(struct lws *wsi, char already_processed, unsigned char c) } #if !defined(LWS_WITHOUT_EXTENSIONS) - if (!lin) + if (!lin && !(already_processed & ALREADY_PROCESSED_FULL_DRAINING)) break; #endif diff --git a/lib/roles/ws/private-lib-roles-ws.h b/lib/roles/ws/private-lib-roles-ws.h index d0b087073f..69033d6cef 100644 --- a/lib/roles/ws/private-lib-roles-ws.h +++ b/lib/roles/ws/private-lib-roles-ws.h @@ -75,6 +75,7 @@ enum lws_websocket_opcodes_07 { #define ALREADY_PROCESSED_IGNORE_CHAR 1 #define ALREADY_PROCESSED_NO_CB 2 +#define ALREADY_PROCESSED_FULL_DRAINING 4 #if !defined(LWS_WITHOUT_EXTENSIONS) struct lws_vhost_role_ws { diff --git a/lib/roles/ws/server-ws.c b/lib/roles/ws/server-ws.c index b8469a4c5e..f746ab31d8 100644 --- a/lib/roles/ws/server-ws.c +++ b/lib/roles/ws/server-ws.c @@ -1080,7 +1080,7 @@ lws_parse_ws(struct lws *wsi, unsigned char **buf, size_t len) wsi->ws->rx_draining_ext); #endif m = lws_ws_rx_sm(wsi, ALREADY_PROCESSED_IGNORE_CHAR | - ALREADY_PROCESSED_NO_CB, 0); + ALREADY_PROCESSED_NO_CB | ALREADY_PROCESSED_FULL_DRAINING, 0); } if (m < 0) {