diff options
author | Cy Schubert <cy@FreeBSD.org> | 2019-12-19 00:11:18 +0000 |
---|---|---|
committer | Cy Schubert <cy@FreeBSD.org> | 2019-12-19 00:11:18 +0000 |
commit | 20616273d52132557e786a8aea1637be4c218a08 (patch) | |
tree | 452ee24d7187b385295c6b2bba5d6324881ef924 | |
parent | 30a580a870fabfea51e4b970c488e58bd1515ce4 (diff) |
Notes
-rw-r--r-- | gencode.c | 9 | ||||
-rw-r--r-- | nametoaddr.c | 9 |
2 files changed, 16 insertions, 2 deletions
diff --git a/gencode.c b/gencode.c index e3425cd9eb95e..3fc97775daed0 100644 --- a/gencode.c +++ b/gencode.c @@ -6955,11 +6955,15 @@ gen_mcode(compiler_state_t *cstate, const char *s1, const char *s2, return (NULL); nlen = __pcap_atoin(s1, &n); + if (nlen < 0) + bpf_error(cstate, "invalid IPv4 address '%s'", s1); /* Promote short ipaddr */ n <<= 32 - nlen; if (s2 != NULL) { mlen = __pcap_atoin(s2, &m); + if (mlen < 0) + bpf_error(cstate, "invalid IPv4 address '%s'", s2); /* Promote short ipaddr */ m <<= 32 - mlen; if ((n & ~m) != 0) @@ -7017,8 +7021,11 @@ gen_ncode(compiler_state_t *cstate, const char *s, bpf_u_int32 v, struct qual q) vlen = __pcap_atodn(s, &v); if (vlen == 0) bpf_error(cstate, "malformed decnet address '%s'", s); - } else + } else { vlen = __pcap_atoin(s, &v); + if (vlen < 0) + bpf_error(cstate, "invalid IPv4 address '%s'", s); + } switch (q.addr) { diff --git a/nametoaddr.c b/nametoaddr.c index 7c48bd3a35132..34a8b5593a649 100644 --- a/nametoaddr.c +++ b/nametoaddr.c @@ -653,8 +653,15 @@ __pcap_atoin(const char *s, bpf_u_int32 *addr) len = 0; for (;;) { n = 0; - while (*s && *s != '.') + while (*s && *s != '.') { + if (n > 25) { + /* The result will be > 255 */ + return -1; + } n = n * 10 + *s++ - '0'; + } + if (n > 255) + return -1; *addr <<= 8; *addr |= n & 0xff; len += 8; |