From: Wlodek Wencel Date: Mon, 18 May 2020 15:09:20 +0000 (+0200) Subject: [#447] exception for incorrect pkt in perfdhcp X-Git-Tag: Kea-1.7.8~18 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=610a49ae3ec6a63bfceeaaf8e87c23dc7c8c2a61;p=thirdparty%2Fkea.git [#447] exception for incorrect pkt in perfdhcp --- diff --git a/src/bin/perfdhcp/perf_socket.cc b/src/bin/perfdhcp/perf_socket.cc index 2beb7a7713..129d1ae5bd 100644 --- a/src/bin/perfdhcp/perf_socket.cc +++ b/src/bin/perfdhcp/perf_socket.cc @@ -150,9 +150,12 @@ Pkt4Ptr PerfSocket::receive4(uint32_t timeout_sec, uint32_t timeout_usec) { Pkt4Ptr pkt = IfaceMgr::instance().receive4(timeout_sec, timeout_usec); if (pkt) { - /// @todo: Add packet exception handling here. Right now any - /// malformed packet will cause perfdhcp to abort. - pkt->unpack(); + try { + pkt->unpack(); + } catch (const std::exception &e) { + std::cout << "Incorrect DHCP packet received" + << e.what() << std::endl; + } } return (pkt); } @@ -161,9 +164,12 @@ Pkt6Ptr PerfSocket::receive6(uint32_t timeout_sec, uint32_t timeout_usec) { Pkt6Ptr pkt = IfaceMgr::instance().receive6(timeout_sec, timeout_usec); if (pkt) { - /// @todo: Add packet exception handling here. Right now any - /// malformed packet will cause perfdhcp to abort. - pkt->unpack(); + try { + pkt->unpack(); + } catch (const std::exception &e) { + std::cout << "Incorrect DHCP packet received" + << e.what() << std::endl; + } } return (pkt); }