Skip to content

Commit

Permalink
fixed: mem allocation issue (ie not being done) with IPv6 extension p…
Browse files Browse the repository at this point in the history
…rocessing in decode().
  • Loading branch information
firnsy committed Mar 4, 2015
1 parent 0e3df2d commit 40b046d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/decode.c
Original file line number Diff line number Diff line change
Expand Up @@ -2192,8 +2192,13 @@ void DecodeIPV6Options(int type, const uint8_t *pkt, uint32_t len, Packet *p)

exthdr = (IP6Extension *)pkt;

p->ip6_extensions[p->ip6_extension_count].type = type;
p->ip6_extensions[p->ip6_extension_count].data = pkt;
/* BY2: we only track the first extension and don't do out of order
** assessment as it's already been done by the engine that built it.
*/
if (p->ip6_extension_count == 0) {
p->ip6_extensions[p->ip6_extension_count].type = type;
p->ip6_extensions[p->ip6_extension_count].data = pkt;
}

// TBD add layers for other ip6 ext headers
switch (type)
Expand Down
3 changes: 3 additions & 0 deletions src/spooler.c
Original file line number Diff line number Diff line change
Expand Up @@ -727,6 +727,8 @@ void spoolerProcessRecord(Spooler *spooler, int fire_output)

/* allocate space for the packet and construct the packet header */
spooler->record.pkt = SnortAlloc(sizeof(Packet));
spooler->record.pkt->ip6_extensions = SnortAlloc(sizeof(IP6Option) * 1);


pkth.caplen = ntohl(((Unified2Packet *)spooler->record.data)->packet_length);
pkth.len = pkth.caplen;
Expand Down Expand Up @@ -798,6 +800,7 @@ void spoolerProcessRecord(Spooler *spooler, int fire_output)
}

/* free the memory allocated in this function */
free(spooler->record.pkt->ip6_extensions);
free(spooler->record.pkt);
spooler->record.pkt = NULL;

Expand Down

0 comments on commit 40b046d

Please sign in to comment.