From 10133ca9b5439e67b287703739e23e7d82fb76c4 Mon Sep 17 00:00:00 2001 From: Robert Bielik Date: Sun, 19 Jan 2020 03:29:52 +0100 Subject: Fix HTTP server root URI handling (#1140) - Fixes #751 --- src/supplemental/http/http_server.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/supplemental/http/http_server.c b/src/supplemental/http/http_server.c index 9a4ff2af..da12c20d 100644 --- a/src/supplemental/http/http_server.c +++ b/src/supplemental/http/http_server.c @@ -676,7 +676,7 @@ http_sconn_cbdone(void *arg) // Get the handler. It may be set regardless of success or // failure. Clear it, and drop our reference, since we're // done with the handler for now. - h = nni_aio_get_data(aio, 1); + h = nni_aio_get_data(aio, 1); nni_aio_set_data(aio, 1, NULL); if (h != NULL) { @@ -1402,8 +1402,9 @@ http_handle_dir(nni_aio *aio) char * pn; len = strlen(base); - if ((strncmp(uri, base, len) != 0) || - ((uri[len] != 0) && (uri[len] != '/'))) { + if (base[1] != '\0' && // Allows "/" as base + ((strncmp(uri, base, len) != 0) || + ((uri[len] != 0) && (uri[len] != '/')))) { // This should never happen! nni_aio_finish_error(aio, NNG_EINVAL); return; -- cgit v1.2.3-70-g09d2