Project

General

Profile

Actions

Bug #2356

closed

coverity issues in new pcap file/directory handling

Added by Victor Julien almost 7 years ago. Updated almost 7 years ago.

Status:
Closed
Priority:
Normal
Target version:
Affected Versions:
Effort:
Difficulty:
Label:

Description

** CID 1426082:  Memory - corruptions  (USE_AFTER_FREE)
/src/source-pcap-file-directory-helper.c: 513 in PcapDirectoryDispatch()

________________________________________________________________________________________________________
*** CID 1426082:  Memory - corruptions  (USE_AFTER_FREE)
/src/source-pcap-file-directory-helper.c: 513 in PcapDirectoryDispatch()
507                     if (PcapDetermineDirectoryOrFile(ptv->filename,
508                                                      &directory_check) == TM_ECODE_FAILED) {
509                         SCLogInfo("Directory %s no longer exists, stopping",
510                                   ptv->filename);
511                         status = TM_ECODE_DONE;
512                     } else {
>>>     CID 1426082:  Memory - corruptions  (USE_AFTER_FREE)
>>>     Calling "closedir" frees pointer "directory_check" which has already been freed.
513                         closedir(directory_check);
514                     }
515                 }
516             } else if (status == TM_ECODE_OK) { //not looping, mark done
517                 SCLogDebug("Not looping, stopping directory mode");
518                 status = TM_ECODE_DONE;

** CID 1426081:  Resource leaks  (RESOURCE_LEAK)
/src/source-pcap-file.c: 274 in ReceivePcapFileThreadInit()

________________________________________________________________________________________________________
*** CID 1426081:  Resource leaks  (RESOURCE_LEAK)
/src/source-pcap-file.c: 274 in ReceivePcapFileThreadInit()
268         } else {
269             SCLogInfo("Argument %s was a directory", (char *)initdata);
270             PcapFileDirectoryVars *pv = SCMalloc(sizeof(PcapFileDirectoryVars));
271             if (unlikely(pv == NULL)) {
272                 SCLogError(SC_ERR_MEM_ALLOC, "Failed to allocate directory vars");
273                 CleanupPcapFileThreadVars(ptv);
>>>     CID 1426081:  Resource leaks  (RESOURCE_LEAK)
>>>     Variable "directory" going out of scope leaks the storage it points to.
274                 SCReturnInt(TM_ECODE_FAILED);
275             }
276             memset(pv, 0, sizeof(PcapFileDirectoryVars));
277     
278             pv->filename = SCStrdup((char*)initdata);
279             if (unlikely(pv->filename == NULL)) {

** CID 1426080:  Resource leaks  (RESOURCE_LEAK)
/src/source-pcap-file-directory-helper.c: 426 in PcapDirectoryDispatchForTimeRange()

________________________________________________________________________________________________________
*** CID 1426080:  Resource leaks  (RESOURCE_LEAK)
/src/source-pcap-file-directory-helper.c: 426 in PcapDirectoryDispatchForTimeRange()
420                     }
421                     memset(pftv, 0, sizeof(PcapFileFileVars));
422     
423                     pftv->filename = SCStrdup(current_file->filename);
424                     if (unlikely(pftv->filename == NULL)) {
425                         SCLogError(SC_ERR_MEM_ALLOC, "Failed to allocate filename");
>>>     CID 1426080:  Resource leaks  (RESOURCE_LEAK)
>>>     Variable "pftv" going out of scope leaks the storage it points to.
426                         SCReturnInt(TM_ECODE_FAILED);
427                     }
428                     pftv->shared = pv->shared;
429     
430                     if (InitPcapFile(pftv) == TM_ECODE_FAILED) {
431                         SCLogWarning(SC_ERR_PCAP_DISPATCH,
Actions #2

Updated by Victor Julien almost 7 years ago

  • Status changed from Assigned to Closed
  • Target version changed from 70 to 4.1beta1
Actions

Also available in: Atom PDF