Bug #42
closedSMB app layer assumes int for pointer arith
Description
app-layer-smb.c assumes that pointer arith results in "int", but on 64-bit linux this is "long int".
EX: static int SMBGetByteCount(Flow *f, void *smb_state, AppLayerParserState *pstate, uint8_t *input, uint32_t input_len, AppLayerParserResult *output)
uint8_t *p = input;
...
SCReturnInt(p - input);
Should return "int", not "long int". On 64-bit Linux and causes compile to fail with debug on (due to debugging output around SCReturnInt() macro) when using '-Wall -Werror -Wextra -Wno-unused-parameter' on 64-bit linux:
if gcc -DHAVE_CONFIG_H -I. -I. -I.. -I/home/brectanus/projects/oisf/deps/include -Wall -Werror -Wextra -Wno-unused-parameter -g -Wall -fno-strict-aliasing -D_BSD_SOURCE -D__BSD_SOURCE -D__FAVOR_BSD -DHAVE_NET_ETHERNET_H -I /usr/include -DLIBPCAP_VERSION_MAJOR=1 -DUNITTESTS -DDEBUG -MT app-layer-smb.o -MD -MP -MF ".deps/app-layer-smb.Tpo" -c -o app-layer-smb.o app-layer-smb.c; \
then mv -f ".deps/app-layer-smb.Tpo" ".deps/app-layer-smb.Po"; else rm -f ".deps/app-layer-smb.Tpo"; exit 1; fi
cc1: warnings being treated as errors
app-layer-smb.c: In function ‘SMBGetByteCount’:
app-layer-smb.c:425: error: format ‘%d’ expects type ‘int’, but argument 4 has type ‘long int’
app-layer-smb.c:425: error: format ‘%d’ expects type ‘int’, but argument 4 has type ‘long int’
app-layer-smb.c: In function ‘SMBParseWordCount’:
app-layer-smb.c:458: error: format ‘%d’ expects type ‘int’, but argument 4 has type ‘long int’
app-layer-smb.c:458: error: format ‘%d’ expects type ‘int’, but argument 4 has type ‘long int’
app-layer-smb.c: In function ‘SMBParseByteCount’:
app-layer-smb.c:499: error: format ‘%d’ expects type ‘int’, but argument 4 has type ‘long int’
app-layer-smb.c:499: error: format ‘%d’ expects type ‘int’, but argument 4 has type ‘long int’
app-layer-smb.c: In function ‘NBSSParseHeader’:
app-layer-smb.c:543: error: format ‘%d’ expects type ‘int’, but argument 4 has type ‘long int’
app-layer-smb.c:543: error: format ‘%d’ expects type ‘int’, but argument 4 has type ‘long int’
app-layer-smb.c: In function ‘SMBParseHeader’:
app-layer-smb.c:701: error: format ‘%d’ expects type ‘int’, but argument 4 has type ‘long int’
app-layer-smb.c:701: error: format ‘%d’ expects type ‘int’, but argument 4 has type ‘long int’
make2: *** [app-layer-smb.o] Error 1
Files