From 7e50d6202c0251cb02b064c83dd941914af92ab0 Mon Sep 17 00:00:00 2001 From: markus Date: Mon, 1 Sep 2008 09:40:43 +0000 Subject: [PATCH] do not overflow for large prefix len (e.g. 2147483649) report Maksymilian Arciemowicz; ok djm, deraadt --- lib/libc/net/inet_net_pton.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) 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. */ -- 2.20.1