From: markus Date: Mon, 1 Sep 2008 09:40:43 +0000 (+0000) Subject: do not overflow for large prefix len (e.g. 2147483649) X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=7e50d6202c0251cb02b064c83dd941914af92ab0;p=openbsd do not overflow for large prefix len (e.g. 2147483649) report Maksymilian Arciemowicz; ok djm, deraadt --- diff --git a/lib/libc/net/inet_net_pton.c b/lib/libc/net/inet_net_pton.c index 9bb35478ca2..3105c33b434 100644 --- a/lib/libc/net/inet_net_pton.c +++ b/lib/libc/net/inet_net_pton.c @@ -1,4 +1,4 @@ -/* $OpenBSD: inet_net_pton.c,v 1.5 2005/08/06 20:30:03 espie Exp $ */ +/* $OpenBSD: inet_net_pton.c,v 1.6 2008/09/01 09:40:43 markus Exp $ */ /* * Copyright (c) 1996 by Internet Software Consortium. @@ -142,12 +142,12 @@ inet_net_pton_ipv4(const char *src, u_char *dst, size_t size) assert(n >= 0 && n <= 9); bits *= 10; bits += n; + if (bits > 32) + goto emsgsize; } while ((ch = *src++) != '\0' && isascii(ch) && isdigit(ch)); if (ch != '\0') goto enoent; - if (bits > 32) - goto emsgsize; } /* Firey death and destruction unless we prefetched EOS. */