client: fix compilation error with GCC 12
authorChristian 'Ansuel' Marangi <ansuelsmth@gmail.com>
Wed, 1 Jun 2022 12:25:32 +0000 (14:25 +0200)
committerChristian 'Ansuel' Marangi <ansuelsmth@gmail.com>
Wed, 1 Jun 2022 12:29:11 +0000 (14:29 +0200)
commitd59d732a10a4a2b9f18af6dfc3facf696108f31e
tree1a78212d05d9cff74f781967c121225577220ebf
parent51283f9f1df5dedcba35f40367ef5d4ab1a55e0b
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>
client.c