summaryrefslogtreecommitdiff
path: root/lib/net_utils.c
diff options
context:
space:
mode:
authorChris Packham <judge.packham@gmail.com>2017-01-04 13:36:26 +1300
committerTom Rini <trini@konsulko.com>2017-01-14 16:47:11 -0500
commitf267e40f9679fec02a3166577c78cb290017b7e3 (patch)
tree6b1e118bc77a3f1ce9cf950d0cc5a1ffd59374b4 /lib/net_utils.c
parentd921ed9a2a553afe0c13638ed339ee42d4572935 (diff)
lib: net_utils: enforce '.' as octet separator in string_to_ip
Ensure '.' is used to separate octets. If another character is seen reject the string outright and return 0.0.0.0. Signed-off-by: Chris Packham <judge.packham@gmail.com>
Diffstat (limited to 'lib/net_utils.c')
-rw-r--r--lib/net_utils.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/lib/net_utils.c b/lib/net_utils.c
index 8f81e780103..d06be22849f 100644
--- a/lib/net_utils.c
+++ b/lib/net_utils.c
@@ -28,6 +28,10 @@ struct in_addr string_to_ip(const char *s)
addr.s_addr = 0;
return addr;
}
+ if (i != 3 && *e != '.') {
+ addr.s_addr = 0;
+ return addr;
+ }
addr.s_addr <<= 8;
addr.s_addr |= (val & 0xFF);
if (s) {