Actions
Bug #1068
closedformat string issues with size_t + qa not catching them
Affected Versions:
Effort:
Difficulty:
Label:
Description
On 32bit clang reports:
clang -DHAVE_CONFIG_H -I. -I.. -I./../libhtp/ -DLOCAL_STATE_DIR=\"/usr/local/var\" -Werror -O0 -ggdb -fsanitize=address -Wextra -Werror-implicit-function-declaration -Wall -fno-strict-aliasing -Wno-unused-parameter -std=gnu99 -DUNITTESTS -DHAVE_LIBNET11 -D_BSD_SOURCE -D__BSD_SOURCE -D__FAVOR_BSD -DHAVE_NET_ETHERNET_H -DHAVE_LIBNET_ICMPV6_UNREACH -I/usr/include -DLIBPCAP_VERSION_MAJOR=1 -DHAVE_PCAP_SET_BUFF -DHAVE_LIBCAP_NG -DREVISION="5ee3649" -MT app-layer-htp.o -MD -MP -MF .deps/app-layer-htp.Tpo -c -o app-layer-htp.o app-layer-htp.c app-layer-htp.c:3188:20: error: format specifies type 'unsigned long long' but the argument has type 'size_t' (aka 'unsigned int') [-Werror,-Wformat] bstr_len(tx_ud->request_uri_normalized)); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ./../libhtp/htp/bstr.h:77:21: note: expanded from macro 'bstr_len' #define bstr_len(X) ((*(X)).len) ^~~~~~~~~~~~
The code is:
printf("normalized uri len should be %"PRIuMAX", is %"PRIuMAX, (uintmax_t)reflen, bstr_len(tx_ud->request_uri_normalized));
Which means clang is correct as bstr_len returns a size_t.
By default in qa we don't check unittests with cocci (for performance reasons IIRC). However, if we do this manually it doesn't report this case:
$ spatch -sp_file qa/coccinelle/size_t.cocci src/app-layer-htp.c init_defs_builtins: /usr/share/coccinelle/standard.h HANDLING: src/app-layer-htp.c
Updated by Eric Leblond about 11 years ago
It seems this is an issue inside coccinelle: https://systeme.lip6.fr/pipermail/cocci/2013-December/000552.html
Updated by Eric Leblond almost 11 years ago
- % Done changed from 0 to 80
Tests have been fixed. A coccinelle fix is the only missing part.
Updated by Victor Julien almost 11 years ago
- Status changed from Assigned to Closed
- % Done changed from 80 to 100
Actions