From 3275eda2efacd383457036cb56da4304fbe2b84b Mon Sep 17 00:00:00 2001 From: shikokuchuo <53399081+shikokuchuo@users.noreply.github.com> Date: Mon, 20 Nov 2023 22:27:04 +0000 Subject: [PATCH] make safe http_schemes.c --- src/supplemental/http/http_schemes.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/supplemental/http/http_schemes.c b/src/supplemental/http/http_schemes.c index df8b92081..95be331fc 100644 --- a/src/supplemental/http/http_schemes.c +++ b/src/supplemental/http/http_schemes.c @@ -76,10 +76,12 @@ static struct { const char * nni_http_stream_scheme(const char *upper) { - for (int i = 0; http_schemes[i].upper != NULL; i++) { - if (strcmp(http_schemes[i].upper, upper) == 0) { - return (http_schemes[i].lower); - } + if (upper != NULL) { + for (int i = 0; http_schemes[i].upper != NULL; i++) { + if (strncmp(http_schemes[i].upper, upper, 7) == 0) { + return (http_schemes[i].lower); + } + } } return (NULL); } \ No newline at end of file