diff options
Diffstat (limited to 'lib/net_utils.c')
-rw-r--r-- | lib/net_utils.c | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/lib/net_utils.c b/lib/net_utils.c index cfae842752..d06be22849 100644 --- a/lib/net_utils.c +++ b/lib/net_utils.c @@ -24,6 +24,14 @@ struct in_addr string_to_ip(const char *s) for (addr.s_addr = 0, i = 0; i < 4; ++i) { ulong val = s ? simple_strtoul(s, &e, 10) : 0; + if (val > 255) { + 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) { |