Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(219)

Unified Diff: webrtc/test/channel_transport/udp_transport_impl.cc

Issue 1615653009: Corrected bug in checking the third number and added extra checks (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webrtc/test/channel_transport/udp_transport_impl.cc
diff --git a/webrtc/test/channel_transport/udp_transport_impl.cc b/webrtc/test/channel_transport/udp_transport_impl.cc
index c7049aa8a2d563abf9bbc91ae9edb4d647e4fea8..897c8085226261bd0d9e61f15acc12568a8b4a1a 100644
--- a/webrtc/test/channel_transport/udp_transport_impl.cc
+++ b/webrtc/test/channel_transport/udp_transport_impl.cc
@@ -2922,6 +2922,10 @@ bool UdpTransport::IsIpAddressValid(const char* ipadr, const bool ipV6)
// Store index of dots and count number of dots.
iDotPos[nDots++] = i;
}
+ else if (isdigit(ipadr[i]) == 0)
+ {
+ return false;
+ }
}
bool allUnder256 = false;
@@ -2942,7 +2946,7 @@ bool UdpTransport::IsIpAddressValid(const char* ipadr, const bool ipV6)
memset(nr,0,4);
strncpy(nr,&ipadr[0],iDotPos[0]);
int32_t num = atoi(nr);
- if (num > 255)
+ if (num > 255 || num < 0)
{
break;
}
@@ -2956,7 +2960,7 @@ bool UdpTransport::IsIpAddressValid(const char* ipadr, const bool ipV6)
memset(nr,0,4);
strncpy(nr,&ipadr[iDotPos[0]+1], iDotPos[1] - iDotPos[0] - 1);
int32_t num = atoi(nr);
- if (num > 255)
+ if (num > 255 || num < 0)
break;
} else {
break;
@@ -2966,20 +2970,27 @@ bool UdpTransport::IsIpAddressValid(const char* ipadr, const bool ipV6)
{
char nr[4];
memset(nr,0,4);
- strncpy(nr,&ipadr[iDotPos[1]+1], iDotPos[1] - iDotPos[0] - 1);
+ strncpy(nr,&ipadr[iDotPos[1]+1], iDotPos[2] - iDotPos[1] - 1);
int32_t num = atoi(nr);
- if (num > 255)
+ if (num > 255 || num < 0)
break;
+ } else {
+ break;
+ }
+ if (len - iDotPos[2] <= 4)
+ {
+ char nr[4];
memset(nr,0,4);
strncpy(nr,&ipadr[iDotPos[2]+1], len - iDotPos[2] -1);
- num = atoi(nr);
- if (num > 255)
+ int32_t num = atoi(nr);
+ if (num > 255 || num < 0)
break;
else
allUnder256 = true;
- } else
+ } else {
break;
+ }
} while(false);
if (nDots != 3 || !allUnder256)
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698