diff mbox series

BUG: case sensitive comparison introduced with 60745832

Message ID 20250508162842.2944148-1-stefano.babic@swupdate.org
State Accepted
Headers show
Series BUG: case sensitive comparison introduced with 60745832 | expand

Commit Message

Stefano Babic May 8, 2025, 4:28 p.m. UTC
Commit 60745832 replace deprecated function mg_ncasecmp() with
strncmp(), that introduces case sensitive comparison. Replace it with
strncasecmp() to be again case insensitive.

Signed-off-by: Stefano Babic <stefano.babic@swupdate.org>
Reported-by: Phil Williams <phil.williams@advisoft.co.nz>
---
 mongoose/mongoose_interface.c | 3 ++-
 mongoose/mongoose_multipart.c | 5 +++--
 2 files changed, 5 insertions(+), 3 deletions(-)
diff mbox series

Patch

diff --git a/mongoose/mongoose_interface.c b/mongoose/mongoose_interface.c
index 9e09533a..fc7eb347 100644
--- a/mongoose/mongoose_interface.c
+++ b/mongoose/mongoose_interface.c
@@ -17,6 +17,7 @@ 
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
+#include <strings.h>
 #include <unistd.h>
 #include <inttypes.h>
 #include <stdbool.h>
@@ -240,7 +241,7 @@  static int mg_check_digest_auth(struct mg_str method, struct mg_str uri,
 			mg_strcmp(auth_domain, mg_str(f_domain)) == 0) {
 			/* Username and domain matched, check the password */
 			mg_mkmd5resp(method, uri, mg_str_s(f_ha1), nonce, nc, cnonce, qop, exp_resp);
-			return strncmp(response.buf, exp_resp, strlen(exp_resp)) == 0;
+			return strncasecmp(response.buf, exp_resp, strlen(exp_resp)) == 0;
 		}
 	}
 
diff --git a/mongoose/mongoose_multipart.c b/mongoose/mongoose_multipart.c
index 4af5d4dc..43e655e7 100644
--- a/mongoose/mongoose_multipart.c
+++ b/mongoose/mongoose_multipart.c
@@ -20,6 +20,7 @@ 
  */
 
 #include "mongoose_multipart.h"
+#include <strings.h>
 
 enum mg_http_multipart_stream_state {
 	MPS_BEGIN,
@@ -203,7 +204,7 @@  static int mg_http_multipart_process_boundary(struct mg_connection *c) {
 		   (line_len = mg_get_line_len(block_begin, data_size)) != 0) {
 		mp_stream->len -= (line_len + 2);
 		if (line_len > sizeof(CONTENT_DISPOSITION) &&
-			strncmp(block_begin, CONTENT_DISPOSITION,
+			strncasecmp(block_begin, CONTENT_DISPOSITION,
 						sizeof(CONTENT_DISPOSITION) - 1) == 0) {
 			struct mg_str header;
 
@@ -219,7 +220,7 @@  static int mg_http_multipart_process_boundary(struct mg_connection *c) {
 			continue;
 		}
 
-		if (line_len == 2 && strncmp(block_begin, "\r\n", 2) == 0) {
+		if (line_len == 2 && strncasecmp(block_begin, "\r\n", 2) == 0) {
 			if (mp_stream->processing_part != 0) {
 				mg_http_multipart_call_handler(c, MG_EV_HTTP_PART_END, NULL, 0);
 			}