Project

General

Profile

Bug #42 » 0001-64-bit-portability.patch

Kirby Kuehl, 01/04/2010 03:14 PM

View differences:

src/app-layer-dcerpc.c
p++;
}
sstate->bytesprocessed += (p - input);
SCReturnInt(p - input);
SCReturnLongInt((long int)(p - input));
}
static int PaddingParser(Flow *f, void *dcerpc_state, AppLayerParserState *pstate,
uint8_t *input, uint32_t input_len, AppLayerParserResult *output) {
SCEnter();
DCERPCState *sstate = (DCERPCState *)dcerpc_state;
uint8_t *p = input;
while (sstate->padleft-- && input_len--) {
......
p++;
}
sstate->bytesprocessed += (p - input);
return (p - input);
SCReturnLongInt((long int)(p - input));
}
static int DCERPCGetCTXItems(Flow *f, void *dcerpc_state, AppLayerParserState *pstate,
......
}
sstate->ctxbytesprocessed += (p - input);
sstate->bytesprocessed += (p - input);
SCReturnInt(p - input);
SCReturnLongInt((long int)(p - input));
}
......
sstate->versionminor |= *(p + 23) << 8;
sstate->uuid_entry = (struct uuid_entry *) calloc(1, sizeof(struct uuid_entry));
if (sstate->uuid_entry == NULL) {
SCReturnInt(-1);
SCReturnLongInt(0L);
} else {
memcpy(sstate->uuid_entry->uuid, sstate->uuid,
sizeof(sstate->uuid));
......
sstate->numctxitemsleft--;
sstate->bytesprocessed += (44);
sstate->ctxbytesprocessed += (44);
SCReturnInt(44);
SCReturnLongInt(44L);
} else {
sstate->ctxid = *(p++);
if (!(--input_len)) break;
......
}
sstate->ctxbytesprocessed += (p - input);
sstate->bytesprocessed += (p - input);
SCReturnInt(p - input);
SCReturnLongInt((long int)(p - input));
}
static int DCERPCParseBINDACKCTXItem(Flow *f, void *dcerpc_state, AppLayerParserState *pstate, uint8_t *input, uint32_t input_len, AppLayerParserResult *output) {
......
TAILQ_FOREACH(uuid_entry, &sstate->uuid_list, next) {
if(uuid_entry->ctxid == sstate->numctxitems - sstate->numctxitemsleft) {
uuid_entry->result = sstate->result;
printUUID("BIND_ACK", uuid_entry);
//printUUID("BIND_ACK", uuid_entry);
break;
}
}
sstate->numctxitemsleft--;
sstate->bytesprocessed += (24);
sstate->ctxbytesprocessed += (24);
SCReturnInt(24);
SCReturnLongInt(24L);
} else {
sstate->result = *(p++);
if (!(--input_len)) break;
......
}
sstate->ctxbytesprocessed += (p - input);
sstate->bytesprocessed += (p - input);
SCReturnInt(p - input);
SCReturnLongInt((long int)(p - input));
}
static int DCERPCParseBIND(Flow *f, void *dcerpc_state, AppLayerParserState *pstate,
......
sstate->numctxitems = *(p+8);
sstate->numctxitemsleft = sstate->numctxitems;
sstate->bytesprocessed += 12;
SCReturnInt(12);
SCReturnLongInt(12L);
} else {
/* max_xmit_frag */
p++;
......
}
}
sstate->bytesprocessed += (p - input);
SCReturnInt(p - input);
SCReturnLongInt((long int)(p - input));
}
static int DCERPCParseBINDACK(Flow *f, void *dcerpc_state, AppLayerParserState *pstate, uint8_t *input, uint32_t input_len, AppLayerParserResult *output) {
......
sstate->secondaryaddrlen |= *(p+9) << 8;
sstate->secondaryaddrlenleft = sstate->secondaryaddrlen;
sstate->bytesprocessed += 10;
SCReturnInt(10);
SCReturnLongInt(10L);
} else {
/* max_xmit_frag */
p++;
......
break;
}
sstate->bytesprocessed += (p - input);
SCReturnInt(p - input);
SCReturnLongInt((long int)(p - input));
}
static int DCERPCParseHeader(Flow *f, void *dcerpc_state, AppLayerParserState
......
sstate->dcerpc.call_id |= *(p + 14) << 8;
sstate->dcerpc.call_id |= *(p + 15);
sstate->bytesprocessed = DCERPC_HDR_LEN;
SCReturnInt(DCERPC_HDR_LEN);
SCReturnLongInt(16L);
break;
} else {
sstate->dcerpc.rpc_vers = *(p++);
......
sstate->dcerpc.call_id |= *(p++);
--input_len;
break;
default: // SHOULD NEVER OCCUR
SCLogDebug("Odd");
SCReturnInt(8);
}
}
sstate->bytesprocessed += (p - input);
SCReturnInt(p - input);
SCReturnLongInt((long int)(p - input));
}
static int DCERPCParse(Flow *f, void *dcerpc_state, AppLayerParserState *pstate, uint8_t *input, uint32_t input_len, AppLayerParserResult *output) {
src/app-layer-smb.c
/* For WriteAndX we need to get writeandxdataoffset */
static int SMBParseWriteAndX(Flow *f, void *smb_state, AppLayerParserState *pstate,
uint8_t *input, uint32_t input_len, AppLayerParserResult *output) {
SCEnter();
SMBState *sstate = (SMBState *) smb_state;
uint8_t *p = input;
switch (sstate->andx.andxbytesprocessed) {
......
sstate->andx.dataoffset|= (uint64_t) *(p+25) << 48;
sstate->andx.dataoffset|= (uint64_t) *(p+26) << 40;
sstate->andx.dataoffset|= (uint64_t) *(p+27) << 32;
input_len -= 28;
sstate->bytesprocessed += 28;
return 28;
SCReturnLongInt(28L);
} else {
sstate->andx.andxcommand = *(p++);
if (!(--input_len)) break;
......
sstate->andx.dataoffset|= (uint64_t) *(p++) << 32;
--input_len;
break;
default:
// SHOULD NEVER OCCUR
return 0;
}
sstate->bytesprocessed += (p - input);
return (p - input);
SCReturnLongInt((long int)(p - input));
}
/**
......
*/
static int SMBParseReadAndX(Flow *f, void *smb_state, AppLayerParserState *pstate,
uint8_t *input, uint32_t input_len, AppLayerParserResult *output) {
SCEnter();
SMBState *sstate = (SMBState *) smb_state;
uint8_t *p = input;
switch (sstate->andx.andxbytesprocessed) {
......
sstate->andx.datalength |= (uint64_t) *(p+15) << 48;
sstate->andx.datalength |= (uint64_t) *(p+16) << 40;
sstate->andx.datalength |= (uint64_t) *(p+17) << 32;
input_len -= 24;
sstate->bytesprocessed += 24;
return 24;
SCReturnLongInt(24L);
} else {
sstate->andx.andxcommand = *(p++);
if (!(--input_len)) break;
......
p++;
--input_len;
break;
default:
// SHOULD NEVER OCCUR
return 0;
}
return 0;
sstate->bytesprocessed += (p - input);
return (p - input);
SCReturnLongInt((long int)(p - input));
}
/**
......
*/
static int PaddingParser(void *smb_state, AppLayerParserState *pstate,
uint8_t *input, uint32_t input_len, AppLayerParserResult *output) {
SCEnter();
SMBState *sstate = (SMBState *) smb_state;
uint8_t *p = input;
while ((uint32_t)(sstate->bytesprocessed + (p - input)) < sstate->andx.dataoffset && sstate->bytecount.bytecount-- && input_len--) {
......
sstate->andx.paddingparsed = 1;
}
sstate->bytesprocessed += (p - input);
return (p - input);
SCReturnLongInt((long int)(p - input));
}
/**
......
*/
static int DataParser(void *smb_state, AppLayerParserState *pstate,
uint8_t *input, uint32_t input_len, AppLayerParserResult *output) {
SCEnter();
SMBState *sstate = (SMBState *) smb_state;
uint8_t *p = input;
......
}
}
sstate->bytesprocessed += (p - input);
return (p - input);
SCReturnLongInt((long int)(p - input));
}
......
sstate->bytecount.bytecountbytes = 0;
sstate->andx.isandx = isAndX(sstate);
SCLogDebug("Wordcount (%u):", sstate->wordcount.wordcount);
SCReturnInt(1);
SCReturnLongInt(1L);
}
SCReturnInt(0);
SCReturnLongInt(0L);
}
/*
......
SCLogDebug("Bytecount %u", sstate->bytecount.bytecount);
--input_len;
}
SCReturnInt(p - input);
SCReturnLongInt((long int)(p - input));
}
/**
......
SCEnter();
SMBState *sstate = (SMBState *) smb_state;
uint8_t *p = input;
uint32_t retval = 0;
long int retval = 0;
uint32_t parsed = 0;
if ((sstate->smb.flags & SMB_FLAGS_SERVER_TO_REDIR) && sstate->smb.command == SMB_COM_READ_ANDX) {
retval = SMBParseReadAndX(f, sstate, pstate, input + parsed, input_len, output);
parsed += retval;
input_len -= retval;
sstate->wordcount.wordcount -= retval;
return retval;
SCReturnLongInt(retval);
} else if (((sstate->smb.flags & SMB_FLAGS_SERVER_TO_REDIR) == 0) && sstate->smb.command == SMB_COM_WRITE_ANDX) {
retval = SMBParseWriteAndX(f, sstate, pstate, input + parsed, input_len, output);
parsed += retval;
input_len -= retval;
sstate->wordcount.wordcount -= retval;
return retval;
SCReturnLongInt(retval);
} else { /* Generic WordCount Handler */
while (sstate->wordcount.wordcount-- && input_len--) {
SCLogDebug("0x%02x ", *p);
p++;
}
sstate->bytesprocessed += (p - input);
SCReturnInt(p - input);
SCReturnLongInt((long int)(p - input));
}
}
......
SCEnter();
SMBState *sstate = (SMBState *) smb_state;
uint8_t *p = input;
uint32_t retval = 0;
long int retval = 0;
uint32_t parsed = 0;
if (((sstate->smb.flags & SMB_FLAGS_SERVER_TO_REDIR) && sstate->smb.command == SMB_COM_READ_ANDX) ||
(((sstate->smb.flags & SMB_FLAGS_SERVER_TO_REDIR) == 0) && sstate->smb.command == SMB_COM_WRITE_ANDX)) {
......
parsed += retval;
input_len -= retval;
}
SCReturnLongInt(retval);
}
while (sstate->bytecount.bytecount && input_len) {
SCLogDebug("0x%02x bytecount %u input_len %u", *p,
sstate->bytecount.bytecount, input_len);
p++;
sstate->wordcount.wordcount--;
input_len--;
}
sstate->bytesprocessed += (p - input);
SCReturnInt(p - input);
SCReturnLongInt((long int)(p - input));
}
//#define DEBUG 1
static int NBSSParseHeader(Flow *f, void *smb_state, AppLayerParserState *pstate,
uint8_t *input, uint32_t input_len, AppLayerParserResult *output)
{
......
sstate->nbss.length = (*(p + 1) & 0x01) << 16;
sstate->nbss.length |= *(p + 2) << 8;
sstate->nbss.length |= *(p + 3);
input_len -= NBSS_HDR_LEN;
sstate->bytesprocessed += NBSS_HDR_LEN;
SCReturnInt(NBSS_HDR_LEN);
SCReturnLongInt(4L);
} else {
sstate->nbss.type = *(p++);
if (!(--input_len)) break;
......
sstate->nbss.length |= *(p++);
--input_len;
break;
default:
SCReturnInt(-1);
break;
}
sstate->bytesprocessed += (p - input);
}
SCReturnInt(p - input);
SCReturnLongInt((long int)(p - input));
}
static int SMBParseHeader(Flow *f, void *smb_state, AppLayerParserState *pstate,
......
if (input_len >= SMB_HDR_LEN) {
if (memcmp(p, "\xff\x53\x4d\x42", 4) != 0) {
SCLogDebug("SMB Header did not validate");
SCReturnInt(0);
SCReturnLongInt(0L);
}
sstate->smb.command = *(p + 4);
sstate->smb.status = *(p + 5) << 24;
......
sstate->smb.uid |= *(p + 29);
sstate->smb.mid = *(p + 30) << 8;
sstate->smb.mid |= *(p + 31);
input_len -= SMB_HDR_LEN;
sstate->bytesprocessed += SMB_HDR_LEN;
SCReturnInt(SMB_HDR_LEN);
SCReturnLongInt(32L);
break;
} else {
//sstate->smb.protocol[0] = *(p++);
......
sstate->smb.mid |= *(p++);
--input_len;
break;
default: // SHOULD NEVER OCCUR
SCReturnInt(8);
}
}
sstate->bytesprocessed += (p - input);
SCReturnInt(p - input);
SCReturnLongInt((long int)(p - input));
}
static int SMBParse(Flow *f, void *smb_state, AppLayerParserState *pstate,
......
*/
int isAndX(SMBState *smb_state) {
SCEnter();
switch (smb_state->smb.command) {
case SMB_NO_SECONDARY_ANDX_COMMAND:
case SMB_COM_LOCKING_ANDX:
......
case SMB_COM_TREE_CONNECT_ANDX:
case SMB_COM_NT_CREATE_ANDX:
smb_state->andx.andxbytesprocessed = 0;
return 1;
SCReturnInt(1);
default:
return 0;
SCReturnInt(0);
}
}
src/app-layer-smb2.c
//#define DEBUG 1
static int NBSSParseHeader(void *smb2_state, AppLayerParserState *pstate,
uint8_t *input, uint32_t input_len, AppLayerParserResult *output) {
SCEnter();
SMB2State *sstate = (SMB2State *) smb2_state;
uint8_t *p = input;
......
sstate->nbss.length = (*(p + 1) & 0x01) << 16;
sstate->nbss.length |= *(p + 2) << 8;
sstate->nbss.length |= *(p + 3);
input_len -= NBSS_HDR_LEN;
sstate->bytesprocessed += NBSS_HDR_LEN;
return NBSS_HDR_LEN;
SCReturnLongInt(4L);
} else {
sstate->nbss.type = *(p++);
if (!(--input_len)) break;
......
sstate->nbss.length |= *(p++);
--input_len;
break;
default:
return -1;
break;
}
sstate->bytesprocessed += (p - input);
}
return (p - input);
SCReturnLongInt((long int)(p - input));
}
static int SMB2ParseHeader(void *smb2_state, AppLayerParserState *pstate,
uint8_t *input, uint32_t input_len, AppLayerParserResult *output) {
SCEnter();
SMB2State *sstate = (SMB2State *) smb2_state;
uint8_t *p = input;
if (input_len) {
......
sstate->smb2.Signature[13] = *(p + 61);
sstate->smb2.Signature[14] = *(p + 62);
sstate->smb2.Signature[15] = *(p + 63);
input_len -= SMB2_HDR_LEN;
sstate->bytesprocessed += SMB2_HDR_LEN;
return SMB2_HDR_LEN;
SCReturnLongInt(64L);
break;
} else {
//sstate->smb2.protocol[0] = *(p++);
......
sstate->smb2.Signature[15] = *(p++);
--input_len;
break;
default: // SHOULD NEVER OCCUR
return 0;
}
}
sstate->bytesprocessed += (p - input);
return (p - input);
SCReturnLongInt((long int)(p - input));
}
static int SMB2Parse(Flow *f, void *smb2_state, AppLayerParserState *pstate,
uint8_t *input, uint32_t input_len, AppLayerParserResult *output) {
SCEnter();
SMB2State *sstate = (SMB2State *) smb2_state;
uint32_t retval = 0;
uint32_t parsed = 0;
......
}
pstate->parse_field = 0;
pstate->flags |= APP_LAYER_PARSER_DONE;
return 1;
SCReturnInt(1);
}
src/util-debug.h
* of the DEBUG macro. Apart from logging function_exit logs, it also
* processes the FD filters, if any FD filters are registered. This
* function_exit macro should be used for functions that returns an
* integer value.
*
* \retval x Variable of type 'integer' that has to be returned
*/
#define SCReturnLongInt(x) do { \
if (sc_log_global_log_level >= SC_LOG_DEBUG) { \
SCLogDebug("Returning: %ld ... <<", x); \
SCLogCheckFDFilterExit(__FUNCTION__); \
} \
return x; \
} while(0)
/**
* \brief Macro used to log debug messages on function exit. Comes under the
* debugging sybsystem, and hence will be enabled only in the presence
* of the DEBUG macro. Apart from logging function_exit logs, it also
* processes the FD filters, if any FD filters are registered. This
* function_exit macro should be used for functions that returns an
* unsigned integer value.
*
* \retval x Variable of type 'unsigned integer' that has to be returned
(1-1/6)