Project

General

Profile

Actions

Bug #42

closed

SMB app layer assumes int for pointer arith

Added by Brian Rectanus over 14 years ago. Updated over 14 years ago.

Status:
Closed
Priority:
Normal
Assignee:
Target version:
-
Affected Versions:
Effort:
Difficulty:
Label:

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

0001-64-bit-portability.patch (22.2 KB) 0001-64-bit-portability.patch Kirby Kuehl, 01/04/2010 03:14 PM
0001-64-bit-fixes-second-try.patch (31.8 KB) 0001-64-bit-fixes-second-try.patch Kirby Kuehl, 01/04/2010 03:35 PM
0001-64-bit-portability.patch (29.7 KB) 0001-64-bit-portability.patch Kirby Kuehl, 01/04/2010 04:52 PM
0001-64-bit-portability.patch (33.5 KB) 0001-64-bit-portability.patch final patch, fixes infinite loop in unittest, uses uint32_t for SCReturnUInt() Kirby Kuehl, 01/05/2010 09:04 AM
0001-64-bit-portability.patch (33.5 KB) 0001-64-bit-portability.patch final patch, fixes infinite loop in unittest, uses uint32_t for SCReturnUInt() Kirby Kuehl, 01/05/2010 09:04 AM
0001-64-bit-portability.patch (33.5 KB) 0001-64-bit-portability.patch final patch, fixes infinite loop in unittest, uses uint32_t for SCReturnUInt() Kirby Kuehl, 01/05/2010 09:05 AM
Actions

Also available in: Atom PDF