Fix warning free compilation of defrag. Fix a missing variable initialization that cause a segv in the unittests.

remotes/origin/master-1.0.x
Victor Julien 16 years ago
parent e0b9e85230
commit 56e45e0c16

@ -154,6 +154,7 @@ static DefragContext *defrag_context;
* Utility/debugging function to dump the frags associated with a * Utility/debugging function to dump the frags associated with a
* tracker. Only enable when unit tests are enabled. * tracker. Only enable when unit tests are enabled.
*/ */
#if 0
#ifdef UNITTESTS #ifdef UNITTESTS
static void static void
DumpFrags(DefragTracker *tracker) DumpFrags(DefragTracker *tracker)
@ -167,6 +168,7 @@ DumpFrags(DefragTracker *tracker)
} }
} }
#endif /* UNITTESTS */ #endif /* UNITTESTS */
#endif
/** /**
* Generate a key for looking of a fragtracker in a hash * Generate a key for looking of a fragtracker in a hash
@ -459,7 +461,7 @@ Defrag4InsertFrag(DefragContext *dc, DefragTracker *tracker, Packet *p)
uint8_t more_frags = IPV4_GET_MF(p); uint8_t more_frags = IPV4_GET_MF(p);
int end = offset + len - hlen; int end = offset + len - hlen;
int ltrim; /* Number of bytes to trim from front of packet. */ int ltrim = 0; /* Number of bytes to trim from front of packet. */
int remove = 0; /* Will be set if we need to remove a fragment. */ int remove = 0; /* Will be set if we need to remove a fragment. */
@ -618,6 +620,7 @@ insert:
mutex_unlock(&dc->frag_pool_lock); mutex_unlock(&dc->frag_pool_lock);
goto done; goto done;
} }
BUG_ON(ltrim > len);
memcpy(new->pkt, (uint8_t *)p->ip4h + ltrim, len - ltrim); memcpy(new->pkt, (uint8_t *)p->ip4h + ltrim, len - ltrim);
new->offset = offset + ltrim; new->offset = offset + ltrim;
new->len = len - ltrim; new->len = len - ltrim;
@ -1424,6 +1427,6 @@ DefragInit(void)
if (defrag_context == NULL) { if (defrag_context == NULL) {
SCLogError(SC_ERR_MEM_ALLOC, SCLogError(SC_ERR_MEM_ALLOC,
"Failed to allocate memory for the Defrag module."); "Failed to allocate memory for the Defrag module.");
exit(1); exit(EXIT_FAILURE);
} }
} }

@ -14,7 +14,7 @@
typedef struct _DefragContext DefragContext; typedef struct _DefragContext DefragContext;
void DefragInit(void); void DefragInit(void);
Packet *Defrag4(ThreadVars *, DefragContext *, DefragContext *); Packet *Defrag4(ThreadVars *, DefragContext *, Packet *);
Packet *Defrag6(DefragContext *, Packet *); Packet *Defrag6(DefragContext *, Packet *);
void DefragRegisterTests(void); void DefragRegisterTests(void);

Loading…
Cancel
Save