Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/netbsd-1-4]: src/lib/libc/net pull up rev 1.13 from trunk (requested by ...
details: https://anonhg.NetBSD.org/src/rev/51c618318ed6
branches: netbsd-1-4
changeset: 469665:51c618318ed6
user: cgd <cgd%NetBSD.org@localhost>
date: Fri Nov 05 07:34:20 1999 +0000
description:
pull up rev 1.13 from trunk (requested by is):
Check for invalid digits in number components. Fixes PR#8314.
diffstat:
lib/libc/net/inet_pton.c | 16 +++++++++++-----
1 files changed, 11 insertions(+), 5 deletions(-)
diffs (46 lines):
diff -r a77b506ce12a -r 51c618318ed6 lib/libc/net/inet_pton.c
--- a/lib/libc/net/inet_pton.c Fri Nov 05 07:30:50 1999 +0000
+++ b/lib/libc/net/inet_pton.c Fri Nov 05 07:34:20 1999 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: inet_pton.c,v 1.9.2.1 1999/10/20 23:57:05 he Exp $ */
+/* $NetBSD: inet_pton.c,v 1.9.2.2 1999/11/05 07:34:20 cgd Exp $ */
/* Copyright (c) 1996 by Internet Software Consortium.
*
@@ -21,7 +21,7 @@
#if 0
static char rcsid[] = "Id: inet_pton.c,v 8.7 1996/08/05 08:31:35 vixie Exp ";
#else
-__RCSID("$NetBSD: inet_pton.c,v 1.9.2.1 1999/10/20 23:57:05 he Exp $");
+__RCSID("$NetBSD: inet_pton.c,v 1.9.2.2 1999/11/05 07:34:20 cgd Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
@@ -95,6 +95,7 @@
u_char *dst;
{
u_int32_t val;
+ u_int digit;
int base, n;
unsigned char c;
u_int parts[4];
@@ -119,11 +120,16 @@
}
for (;;) {
if (isdigit(c)) {
- val = (val * base) + (c - '0');
+ digit = c - '0';
+ if (digit >= base)
+ break;
+ val = (val * base) + digit;
c = *++src;
} else if (base == 16 && isxdigit(c)) {
- val = (val << 4) |
- (c + 10 - (islower(c) ? 'a' : 'A'));
+ digit = c + 10 - (islower(c) ? 'a' : 'A');
+ if (digit >= 16)
+ break;
+ val = (val << 4) | digit;
c = *++src;
} else
break;
Home |
Main Index |
Thread Index |
Old Index