File tree Expand file tree Collapse file tree 2 files changed +11
-1
lines changed
Expand file tree Collapse file tree 2 files changed +11
-1
lines changed Original file line number Diff line number Diff line change @@ -281,7 +281,7 @@ std::vector<IPv4Address>& PcapLiveDeviceList::getDnsServers()
281281PcapLiveDevice* PcapLiveDeviceList::getPcapLiveDeviceByIp (const char * ipAddrAsString)
282282{
283283 IPAddress::Ptr_t apAddr = IPAddress::fromString (ipAddrAsString);
284- if (!apAddr->isValid ())
284+ if (apAddr. get () == NULL || !apAddr->isValid ())
285285 {
286286 LOG_ERROR (" IP address illegal" );
287287 return NULL ;
Original file line number Diff line number Diff line change @@ -1268,6 +1268,15 @@ PCAPP_TEST(TestPcapLiveDevice)
12681268 PCAPP_TEST_PASSED;
12691269}
12701270
1271+ PCAPP_TEST (TestPcapLiveDeviceByInvalidIp)
1272+ {
1273+ PcapLiveDevice* liveDev = NULL ;
1274+ liveDev = PcapLiveDeviceList::getInstance ().getPcapLiveDeviceByIp (" eth0" );
1275+ PCAPP_ASSERT (liveDev == NULL , " Cannot get live device by invalid Ip" );
1276+
1277+ PCAPP_TEST_PASSED;
1278+ }
1279+
12711280PCAPP_TEST (TestPcapLiveDeviceNoNetworking)
12721281{
12731282 PcapLiveDevice* liveDev = NULL ;
@@ -5593,6 +5602,7 @@ int main(int argc, char* argv[])
55935602 PCAPP_RUN_TEST (TestPcapLiveDeviceStatsMode, args, true );
55945603 PCAPP_RUN_TEST (TestPcapLiveDeviceBlockingMode, args, true );
55955604 PCAPP_RUN_TEST (TestWinPcapLiveDevice, args, true );
5605+ PCAPP_RUN_TEST (TestPcapLiveDeviceByInvalidIp, args, false );
55965606 PCAPP_RUN_TEST (TestPcapFilters, args, true );
55975607 PCAPP_RUN_TEST (TestSendPacket, args, true );
55985608 PCAPP_RUN_TEST (TestSendPackets, args, true );
You can’t perform that action at this time.
0 commit comments