]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
Fix Coverity 1220098 and 1220099 981/head
authorVictor Julien <victor@inliniac.net>
Wed, 4 Jun 2014 15:11:29 +0000 (17:11 +0200)
committerVictor Julien <victor@inliniac.net>
Wed, 4 Jun 2014 15:11:29 +0000 (17:11 +0200)
*** CID 1220098:  Missing unlock  (LOCK)
/src/log-droplog.c: 195 in LogDropLogNetFilter()
189         SCMutexLock(&dlt->file_ctx->fp_mutex);
190
191         if (dlt->file_ctx->rotation_flag) {
192             dlt->file_ctx->rotation_flag  = 0;
193             if (SCConfLogReopen(dlt->file_ctx) != 0) {
194                 /* Rotation failed, error already logged. */
>>>     CID 1220098:  Missing unlock  (LOCK)
>>>     Returning without unlocking "dlt->file_ctx->fp_mutex".
195                 return TM_ECODE_FAILED;
196             }
197         }
198
199         if (dlt->file_ctx == NULL) {
200             return TM_ECODE_FAILED;

*** CID 1220099:  Dereference before null check  (REVERSE_INULL)
/src/log-droplog.c: 199 in LogDropLogNetFilter()
193             if (SCConfLogReopen(dlt->file_ctx) != 0) {
194                 /* Rotation failed, error already logged. */
195                 return TM_ECODE_FAILED;
196             }
197         }
198
>>>     CID 1220099:  Dereference before null check  (REVERSE_INULL)
>>>     Null-checking "dlt->file_ctx" suggests that it may be null, but it has already been dereferenced on all paths leading to the check.
199         if (dlt->file_ctx == NULL) {
200             return TM_ECODE_FAILED;
201         }
202
203         char srcip[46] = "";
204         char dstip[46] = "";

src/log-droplog.c

index 5a50d89b55c577e3dd8002efef8a66a07314923a..74a81fb52c40b523093698277d5b9175f72458ba 100644 (file)
@@ -192,14 +192,11 @@ static int LogDropLogNetFilter (ThreadVars *tv, const Packet *p, void *data)
         dlt->file_ctx->rotation_flag  = 0;
         if (SCConfLogReopen(dlt->file_ctx) != 0) {
             /* Rotation failed, error already logged. */
+            SCMutexUnlock(&dlt->file_ctx->fp_mutex);
             return TM_ECODE_FAILED;
         }
     }
 
-    if (dlt->file_ctx == NULL) {
-        return TM_ECODE_FAILED;
-    }
-
     char srcip[46] = "";
     char dstip[46] = "";