fix(esp_http_server): fix ws server subprotocol match

This commit is contained in:
Ashish Sharma
2026-02-24 16:29:53 +08:00
parent 9df5d023bc
commit 4e9367bc41
2 changed files with 3 additions and 1 deletions

View File

@@ -509,6 +509,8 @@ static int read_block(httpd_req_t *req, http_parser *parser, size_t offset, size
if (new_scratch == NULL) {
free(raux->scratch);
raux->scratch = NULL;
/* Set last.at to NULL to avoid accidental dereference of dangling pointer */
parser_data->last.at = NULL;
ESP_LOGE(TAG, "Unable to allocate the scratch buffer");
return 0;
}

View File

@@ -83,7 +83,7 @@ static bool httpd_ws_get_response_subprotocol(const char *supported_subprotocol,
char *rest = NULL;
char *s = strtok_r(subprotocol, ", ", &rest);
do {
if (strncmp(s, supported_subprotocol, sizeof(subprotocol)) == 0) {
if (strncmp(s, supported_subprotocol, strlen(supported_subprotocol)) == 0) {
ESP_LOGD(TAG, "Requested subprotocol supported: %s", s);
return true;
}