stream: workaround scan-build warnings

stream-tcp.c:1938:16: warning: Access to field 'next' results in a dereference of a null pointer (loaded from variable 'tail') [core.NullDereference]
 1938 |     tail->next = old_head;
      |     ~~~~       ^
1 warning generated.

stream-tcp.c:1982:5: warning: Potential leak of memory pointed to by 'q' [unix.Malloc]
 1982 |     ssn->queue_len++;
      |     ^~~
1 warning generated.
pull/13817/head
Victor Julien 2 months ago committed by Victor Julien
parent d352b75ac6
commit f333a528f3

@ -1951,7 +1951,8 @@ static int StreamTcp3whsStoreSyn(TcpSession *ssn, Packet *p)
if (ssn->queue != NULL && StreamTcp3whsFindSyn(ssn, &search, &tail, false) != NULL)
return 0;
if (ssn->queue_len == stream_config.max_syn_queued) {
if (ssn->queue_len > 0 && ssn->queue_len == stream_config.max_syn_queued) {
DEBUG_VALIDATE_BUG_ON(ssn->queue == NULL);
SCLogDebug("%" PRIu64 ": ssn %p: =~ SYN queue limit reached, rotate", p->pcap_cnt, ssn);
StreamTcpSetEvent(p, STREAM_3WHS_SYN_FLOOD);
@ -1974,10 +1975,12 @@ static int StreamTcp3whsStoreSyn(TcpSession *ssn, Packet *p)
*q = search;
/* put in list */
if (tail)
if (tail) {
tail->next = q;
if (ssn->queue == NULL)
} else {
DEBUG_VALIDATE_BUG_ON(ssn->queue != NULL);
ssn->queue = q;
}
ssn->queue_len++;
SCLogDebug("%" PRIu64 ": ssn %p: =~ SYN with SEQ %u added (queue_len %u)", p->pcap_cnt, ssn,
q->seq, ssn->queue_len);

Loading…
Cancel
Save