Skip to content

Commit

Permalink
Fix LightPcapNg null derefs found by oss-fuzz (#1232)
Browse files Browse the repository at this point in the history
  • Loading branch information
sashashura authored Nov 10, 2023
1 parent 6a67cab commit 0c95dfb
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
3 changes: 2 additions & 1 deletion 3rdParty/LightPcapNg/LightPcapNg/src/light_pcapng_ext.c
Original file line number Diff line number Diff line change
Expand Up @@ -558,7 +558,8 @@ void light_pcapng_close(light_pcapng_t *pcapng)
light_flush(pcapng->file);
light_close(pcapng->file);
}
light_free_file_info(pcapng->file_info);
if (pcapng->file_info != NULL)
light_free_file_info(pcapng->file_info);
free(pcapng);
}

Expand Down
8 changes: 8 additions & 0 deletions Pcap++/src/PcapFileDevice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -439,6 +439,8 @@ std::string PcapNgFileReaderDevice::getOS() const
}

light_pcapng_file_info* fileInfo = light_pcang_get_file_info((light_pcapng_t*)m_LightPcapNg);
if (fileInfo == nullptr)
return "";
char* res = fileInfo->os_desc;
size_t len = fileInfo->os_desc_size;
if (len == 0 || res == nullptr)
Expand All @@ -456,6 +458,8 @@ std::string PcapNgFileReaderDevice::getHardware() const
}

light_pcapng_file_info* fileInfo = light_pcang_get_file_info((light_pcapng_t*)m_LightPcapNg);
if (fileInfo == nullptr)
return "";
char* res = fileInfo->hardware_desc;
size_t len = fileInfo->hardware_desc_size;
if (len == 0 || res == nullptr)
Expand All @@ -473,6 +477,8 @@ std::string PcapNgFileReaderDevice::getCaptureApplication() const
}

light_pcapng_file_info* fileInfo = light_pcang_get_file_info((light_pcapng_t*)m_LightPcapNg);
if (fileInfo == nullptr)
return "";
char* res = fileInfo->user_app_desc;
size_t len = fileInfo->user_app_desc_size;
if (len == 0 || res == nullptr)
Expand All @@ -490,6 +496,8 @@ std::string PcapNgFileReaderDevice::getCaptureFileComment() const
}

light_pcapng_file_info* fileInfo = light_pcang_get_file_info((light_pcapng_t*)m_LightPcapNg);
if (fileInfo == nullptr)
return "";
char* res = fileInfo->file_comment;
size_t len = fileInfo->file_comment_size;
if (len == 0 || res == nullptr)
Expand Down

0 comments on commit 0c95dfb

Please sign in to comment.