From dfbe8ef5d7f538e1ab722af65b44f52c1438b011 Mon Sep 17 00:00:00 2001 From: jhorck Date: Mon, 15 Dec 2014 10:11:53 +0100 Subject: [PATCH] Update Dns.cpp valid IP address digits have to be >= 0 AND <= 9 valid IP addresses must have 4 segments --- libraries/Ethernet/src/Dns.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/libraries/Ethernet/src/Dns.cpp b/libraries/Ethernet/src/Dns.cpp index 62e36f8a335..d4adb35abe4 100644 --- a/libraries/Ethernet/src/Dns.cpp +++ b/libraries/Ethernet/src/Dns.cpp @@ -60,7 +60,7 @@ int DNSClient::inet_aton(const char* aIPAddrString, IPAddress& aResult) // See if we've been given a valid IP address const char* p =aIPAddrString; while (*p && - ( (*p == '.') || (*p >= '0') || (*p <= '9') )) + ( (*p == '.') || ((*p >= '0') && (*p <= '9')) )) { p++; } @@ -97,10 +97,10 @@ int DNSClient::inet_aton(const char* aIPAddrString, IPAddress& aResult) } // We've reached the end of address, but there'll still be the last // segment to deal with - if ((segmentValue > 255) || (segment > 3)) + if ((segmentValue > 255) || (segment != 3)) { // You can't have IP address segments that don't fit in a byte, - // or more than four segments + // or other than four segments return 0; } else