summaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
authormillert <>2017-03-06 18:16:27 +0000
committermillert <>2017-03-06 18:16:27 +0000
commit6e1b969bcaca824c560d5b4adb5de8d84e439819 (patch)
tree181df8ba91be700b90a1eee36c817c2b8005ade8 /src/lib
parentfd95a9dab8a07c61c805cb7f2f736b95364c2d06 (diff)
downloadopenbsd-6e1b969bcaca824c560d5b4adb5de8d84e439819.tar.gz
openbsd-6e1b969bcaca824c560d5b4adb5de8d84e439819.tar.bz2
openbsd-6e1b969bcaca824c560d5b4adb5de8d84e439819.zip
size is unsigned so using ==0 not <=0 when checking for buffer exhaustion
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/libc/net/inet_net_pton.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/lib/libc/net/inet_net_pton.c b/src/lib/libc/net/inet_net_pton.c
index 61ea34c906..2aaeac4048 100644
--- a/src/lib/libc/net/inet_net_pton.c
+++ b/src/lib/libc/net/inet_net_pton.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: inet_net_pton.c,v 1.9 2017/03/06 18:14:41 millert Exp $ */ 1/* $OpenBSD: inet_net_pton.c,v 1.10 2017/03/06 18:16:27 millert Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 2012 by Gilles Chehade <gilles@openbsd.org> 4 * Copyright (c) 2012 by Gilles Chehade <gilles@openbsd.org>
@@ -89,7 +89,7 @@ inet_net_pton_ipv4(const char *src, u_char *dst, size_t size)
89 if (ch == '0' && (src[0] == 'x' || src[0] == 'X') 89 if (ch == '0' && (src[0] == 'x' || src[0] == 'X')
90 && isascii((unsigned char)src[1]) && isxdigit((unsigned char)src[1])) { 90 && isascii((unsigned char)src[1]) && isxdigit((unsigned char)src[1])) {
91 /* Hexadecimal: Eat nybble string. */ 91 /* Hexadecimal: Eat nybble string. */
92 if (size <= 0) 92 if (size == 0)
93 goto emsgsize; 93 goto emsgsize;
94 tmp = 0, dirty = 0; 94 tmp = 0, dirty = 0;
95 src++; /* skip x or X. */ 95 src++; /* skip x or X. */
@@ -128,7 +128,7 @@ inet_net_pton_ipv4(const char *src, u_char *dst, size_t size)
128 goto enoent; 128 goto enoent;
129 } while ((ch = (unsigned char)*src++) != '\0' && 129 } while ((ch = (unsigned char)*src++) != '\0' &&
130 isascii(ch) && isdigit(ch)); 130 isascii(ch) && isdigit(ch));
131 if (size-- <= 0) 131 if (size-- == 0)
132 goto emsgsize; 132 goto emsgsize;
133 *dst++ = (u_char) tmp; 133 *dst++ = (u_char) tmp;
134 if (ch == '\0' || ch == '/') 134 if (ch == '\0' || ch == '/')
@@ -186,7 +186,7 @@ inet_net_pton_ipv4(const char *src, u_char *dst, size_t size)
186 } 186 }
187 /* Extend network to cover the actual mask. */ 187 /* Extend network to cover the actual mask. */
188 while (bits > ((dst - odst) * 8)) { 188 while (bits > ((dst - odst) * 8)) {
189 if (size-- <= 0) 189 if (size-- == 0)
190 goto emsgsize; 190 goto emsgsize;
191 *dst++ = '\0'; 191 *dst++ = '\0';
192 } 192 }