summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian 'Ansuel' Marangi <ansuelsmth@gmail.com>2022-06-01 14:25:32 +0200
committerChristian 'Ansuel' Marangi <ansuelsmth@gmail.com>2022-06-01 14:29:11 +0200
commitd59d732a10a4a2b9f18af6dfc3facf696108f31e (patch)
tree1a78212d05d9cff74f781967c121225577220ebf
parent51283f9f1df5dedcba35f40367ef5d4ab1a55e0b (diff)
client: fix compilation error with GCC 12
Using GCC 12 on an aarch64 target the following compilation error is printed. ninja: Entering directory `/home/ansuel/openwrt/build_dir/target-aarch64_cortex-a53_musl/uhttpd-2022-02-07-2f8b1360' [1/2] Building C object CMakeFiles/uhttpd.dir/client.c.o FAILED: CMakeFiles/uhttpd.dir/client.c.o /home/ansuel/openwrt/staging_dir/host/bin/ccache /home/ansuel/openwrt/staging_dir/toolchain-aarch64_cortex-a53_gcc-12.1.0_musl/bin/aarch64-openwrt-linux-musl-gcc -DHAVE_LUA -DHAVE_SHADOW -DHAVE_TLS -DHAVE_UBUS -DHAVE_UCODE -D_FILE_OFFSET_BITS=64 -Os -pipe -mcpu=cortex-a53 -fno-caller-saves -fno-plt -fhonour-copts -Wno-error=unused-but-set-variable -Wno-error=unused-result -fmacro-prefix-map=/home/ansuel/openwrt/build_dir/target-aarch64_cortex-a53_musl/uhttpd-2022-02-07-2f8b1360=uhttpd-2022-02-07-2f8b1360 -Wformat -Werror=format-security -DPIC -fPIC -fstack-protector -D_FORTIFY_SOURCE=1 -Wl,-z,now -Wl,-z,relro -DNDEBUG -Os -Wall -Werror -Wmissing-declarations --std=gnu99 -g3 -MD -MT CMakeFiles/uhttpd.dir/client.c.o -MF CMakeFiles/uhttpd.dir/client.c.o.d -o CMakeFiles/uhttpd.dir/client.c.o -c /home/ansuel/openwrt/build_dir/target-aarch64_cortex-a53_musl/uhttpd-2022-02-07-2f8b1360/client.c In function 'tls_redirect_check', inlined from 'client_header_complete' at client.c:306:7, inlined from 'client_parse_header' at client.c:338:3, inlined from 'client_header_cb' at client.c:502:2: client.c:269:22: error: 'strcmp' reading 1 or more bytes from a region of size 0 [-Werror=stringop-overread] 269 | if (!strcmp(blobmsg_name(cur), "URL")) | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ cc1: all warnings being treated as errors ninja: build stopped: subcommand failed. Fix this by using the strncmp variant. Signed-off-by: Christian 'Ansuel' Marangi <ansuelsmth@gmail.com>
-rw-r--r--client.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/client.c b/client.c
index 2be8f22..06336eb 100644
--- a/client.c
+++ b/client.c
@@ -263,10 +263,10 @@ static bool tls_redirect_check(struct client *cl)
return true;
blob_for_each_attr(cur, cl->hdr.head, rem) {
- if (!strcmp(blobmsg_name(cur), "host"))
+ if (!strncmp(blobmsg_name(cur), "host", 4))
host = blobmsg_get_string(cur);
- if (!strcmp(blobmsg_name(cur), "URL"))
+ if (!strncmp(blobmsg_name(cur), "URL", 3))
url = blobmsg_get_string(cur);
if (url && host)