Another batch of minor fixed for issues found by Coverity.

remotes/origin/HEAD
Victor Julien 14 years ago
parent 11bdf4838f
commit 372ab9c433

@ -377,7 +377,6 @@ int FlowForceReassemblyForFlowV2(Flow *f)
} else if (server_ok == 2) {
p1 = FlowForceReassemblyPseudoPacketGet(1, f, ssn, 1);
if (p1 == NULL) {
TmqhOutputPacketpool(NULL, p1);
return 1;
}
} else {

@ -423,16 +423,18 @@ OutputCtx *PcapLogInitCtx(ConfNode *conf)
{
SCMutexLock(&plog_lock);
const char *filename = NULL;
if (conf != NULL) { /* To faciliate unit tests. */
filename = ConfNodeLookupChildValue(conf, "filename");
}
if (filename == NULL)
filename = DEFAULT_LOG_FILENAME;
if ((pl->prefix = SCStrdup(filename)) == NULL) {
SCLogError(SC_ERR_MEM_ALLOC, "Error allocating memory for directory name");
return NULL;
SCLogError(SC_ERR_MEM_ALLOC, "Error allocating memory for directory name");
SCMutexUnlock(&plog_lock);
return NULL;
}
pl->size_limit = DEFAULT_LIMIT;

@ -262,37 +262,21 @@ void StreamTcpSackPruneList(TcpStream *stream) {
SCEnter();
StreamTcpSackRecord *rec = stream->sack_head;
StreamTcpSackRecord *prev = NULL;
while (rec != NULL) {
if (SEQ_LT(rec->re, stream->last_ack)) {
SCLogDebug("removing le %u re %u", rec->le, rec->re);
// fully before last_ack, remove
if (prev != NULL) {
if (rec == stream->sack_tail) {
stream->sack_tail = prev;
prev->next = NULL;
SCFree(rec);
break;
} else {
prev->next = rec->next;
SCFree(rec);
rec = prev->next;
continue;
}
if (rec->next != NULL) {
stream->sack_head = rec->next;
SCFree(rec);
rec = stream->sack_head;
continue;
} else {
if (rec->next != NULL) {
stream->sack_head = rec->next;
SCFree(rec);
rec = stream->sack_head;
continue;
} else {
stream->sack_head = NULL;
stream->sack_tail = NULL;
SCFree(rec);
break;
}
stream->sack_head = NULL;
stream->sack_tail = NULL;
SCFree(rec);
break;
}
} else if (SEQ_LT(rec->le, stream->last_ack)) {
SCLogDebug("adjusting record to le %u re %u", rec->le, rec->re);

@ -667,6 +667,9 @@ void StreamTcpSetOSPolicy(TcpStream *stream, Packet *p)
* \param tv Thread Variable containig input/output queue, cpu affinity
* \param p Packet which has to be handled in this TCP state.
* \param stt Strean Thread module registered to handle the stream handling
*
* \retval 0 ok
* \retval -1 error
*/
static int StreamTcpPacketStateNone(ThreadVars *tv, Packet *p,
StreamTcpThread *stt, TcpSession *ssn, PacketQueue *pq)
@ -924,6 +927,7 @@ static int StreamTcpPacketStateNone(ThreadVars *tv, Packet *p,
SCLogDebug("default case");
break;
}
return 0;
}
@ -3749,39 +3753,40 @@ static int StreamTcpPacket (ThreadVars *tv, Packet *p, StreamTcpThread *stt,
* inject a fake packet into the system, forcing reassembly of the
* opposing direction.
* There should be only one, but to be sure we do a while loop. */
while (stt->pseudo_queue.len > 0) {
SCLogDebug("processing pseudo packet / stream end");
Packet *np = PacketDequeue(&stt->pseudo_queue);
if (np != NULL) {
/* process the opposing direction of the original packet */
if (PKT_IS_TOSERVER(np)) {
SCLogDebug("pseudo packet is to server");
StreamTcpReassembleHandleSegment(tv, stt->ra_ctx, ssn,
&ssn->client, np, NULL);
} else {
SCLogDebug("pseudo packet is to client");
StreamTcpReassembleHandleSegment(tv, stt->ra_ctx, ssn,
&ssn->server, np, NULL);
if (ssn != NULL) {
while (stt->pseudo_queue.len > 0) {
SCLogDebug("processing pseudo packet / stream end");
Packet *np = PacketDequeue(&stt->pseudo_queue);
if (np != NULL) {
/* process the opposing direction of the original packet */
if (PKT_IS_TOSERVER(np)) {
SCLogDebug("pseudo packet is to server");
StreamTcpReassembleHandleSegment(tv, stt->ra_ctx, ssn,
&ssn->client, np, NULL);
} else {
SCLogDebug("pseudo packet is to client");
StreamTcpReassembleHandleSegment(tv, stt->ra_ctx, ssn,
&ssn->server, np, NULL);
}
/* enqueue this packet so we inspect it in detect etc */
PacketEnqueue(pq, np);
}
SCLogDebug("processing pseudo packet / stream end done");
}
/* enqueue this packet so we inspect it in detect etc */
PacketEnqueue(pq, np);
/* Process stream smsgs we may have in queue */
if (StreamTcpReassembleProcessAppLayer(stt->ra_ctx) < 0) {
goto error;
}
SCLogDebug("processing pseudo packet / stream end done");
}
/* Process stream smsgs we may have in queue */
if (StreamTcpReassembleProcessAppLayer(stt->ra_ctx) < 0) {
goto error;
}
/* recalc the csum on the packet if it was modified */
if (p->flags & PKT_STREAM_MODIFIED) {
ReCalculateChecksum(p);
}
/* recalc the csum on the packet if it was modified */
if (p->flags & PKT_STREAM_MODIFIED) {
ReCalculateChecksum(p);
}
/* check for conditions that may make us not want to log this packet */
/* check for conditions that may make us not want to log this packet */
if (ssn != NULL) {
/* streams that hit depth */
if ((ssn->client.flags & STREAMTCP_STREAM_FLAG_DEPTH_REACHED ||
ssn->server.flags & STREAMTCP_STREAM_FLAG_DEPTH_REACHED))

@ -105,7 +105,6 @@ void *TmThreadsSlot1NoIn(void *td)
{
ThreadVars *tv = (ThreadVars *)td;
TmSlot *s = (TmSlot *)tv->tm_slots;
Packet *p = NULL;
char run = 1;
TmEcode r = TM_ECODE_OK;
@ -136,7 +135,7 @@ void *TmThreadsSlot1NoIn(void *td)
TmThreadTestThreadUnPaused(tv);
PACKET_PROFILING_TMM_START(p, s->tm_id);
r = s->SlotFunc(tv, p, s->slot_data, &s->slot_pre_pq, &s->slot_post_pq);
r = s->SlotFunc(tv, NULL, s->slot_data, &s->slot_pre_pq, &s->slot_post_pq);
PACKET_PROFILING_TMM_END(p, s->tm_id);
/* handle error */
@ -147,8 +146,6 @@ void *TmThreadsSlot1NoIn(void *td)
TmqhReleasePacketsToPacketPool(&s->slot_post_pq);
SCMutexUnlock(&s->slot_post_pq.mutex_q);
if (p != NULL)
TmqhOutputPacketpool(tv, p);
TmThreadsSetFlag(tv, THV_FAILED);
break;
}
@ -160,10 +157,6 @@ void *TmThreadsSlot1NoIn(void *td)
tv->tmqh_out(tv, extra_p);
}
tv->tmqh_out(tv, p);
if (p != NULL)
tv->tmqh_out(tv, p);
/* handle post queue */
if (s->slot_post_pq.top != NULL) {
SCMutexLock(&s->slot_post_pq.mutex_q);
@ -557,7 +550,7 @@ void *TmThreadsSlotPktAcqLoop(void *td) {
SCLogError(SC_ERR_FATAL, "TmSlot or ThreadVars badly setup: s=%p,"
" PktAcqLoop=%p, tmqh_in=%p,"
" tmqh_out=%p",
s, s->PktAcqLoop, tv->tmqh_in, tv->tmqh_out);
s, s ? s->PktAcqLoop : NULL, tv->tmqh_in, tv->tmqh_out);
EngineKill();
TmThreadsSetFlag(tv, THV_CLOSED);

@ -792,10 +792,6 @@ int RunModeSetIPSAuto(DetectEngineCtx *de_ctx,
}
memset(tname, 0, sizeof(tname));
snprintf(tname, sizeof(tname), "Recv-Q%s", cur_queue);
if (tname == NULL) {
printf("ERROR: Unable to build thread name\n");
exit(EXIT_FAILURE);
}
char *thread_name = SCStrdup(tname);
ThreadVars *tv_receivenfq =
@ -1003,10 +999,6 @@ int RunModeSetIPSAutoFp(DetectEngineCtx *de_ctx,
}
memset(tname, 0, sizeof(tname));
snprintf(tname, sizeof(tname), "Recv-Q%s", cur_queue);
if (tname == NULL) {
printf("ERROR: Unable to build thread name\n");
exit(EXIT_FAILURE);
}
char *thread_name = SCStrdup(tname);

Loading…
Cancel
Save