Possible bug in ESP8266-ping 2.0.1 – missing ICMP source IP validation

Hello,

I am using the ESP8266-ping library by Alessio Leoncini (version 2.0.1) with an ESP8266 NodeMCU.

While investigating occasional incorrect ping results when pinging several devices sequentially, I noticed a possible issue in Pinger.cpp, function PingReceived().

The function receives the actual source IP address of the incoming packet as the parameter:

const ip_addr_t * addr

However, the response validation currently checks only the ICMP identifier, sequence number and message type:

if (echoResponseHeader->id == m_packetId &&
    echoResponseHeader->seqno == htons(m_pingResponse.SequenceNumber) &&
    echoResponseHeader->type == ICMP_ER)

There appears to be no check that the actual source IP address matches the destination IP address of the current ping request (m_pingResponse.DestIPAddress).

Could this allow an ICMP response from another host to be accepted as a response from the currently pinged host, if the ICMP identifier and sequence number match?

I suggest adding a source IP address check before accepting the response.

Unfortunately, the original GitHub repository seems to be unavailable (404), so I am posting this here in the hope that the original author or someone familiar with the library can comment.

Has anyone investigated this issue or considered a fix?

Thank you!