diff options
| author | deraadt <> | 1996-07-27 10:45:26 +0000 |
|---|---|---|
| committer | deraadt <> | 1996-07-27 10:45:26 +0000 |
| commit | f4c9be3243403d728030bb01603f41e6f5c061bc (patch) | |
| tree | 65bdb513fc1b9b5db4b407c783d2eaa4911d0c96 /src/lib/libc/stdlib/strtoul.c | |
| parent | 790e572a83b827ace1ed6ee87a9614e24af34d85 (diff) | |
| download | openbsd-f4c9be3243403d728030bb01603f41e6f5c061bc.tar.gz openbsd-f4c9be3243403d728030bb01603f41e6f5c061bc.tar.bz2 openbsd-f4c9be3243403d728030bb01603f41e6f5c061bc.zip | |
be very careful in case of signed chars
Diffstat (limited to 'src/lib/libc/stdlib/strtoul.c')
| -rw-r--r-- | src/lib/libc/stdlib/strtoul.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/src/lib/libc/stdlib/strtoul.c b/src/lib/libc/stdlib/strtoul.c index 1522bec584..9d45c5cb9e 100644 --- a/src/lib/libc/stdlib/strtoul.c +++ b/src/lib/libc/stdlib/strtoul.c | |||
| @@ -33,7 +33,7 @@ | |||
| 33 | 33 | ||
| 34 | #if defined(LIBC_SCCS) && !defined(lint) | 34 | #if defined(LIBC_SCCS) && !defined(lint) |
| 35 | /*static char *sccsid = "from: @(#)strtoul.c 5.3 (Berkeley) 2/23/91";*/ | 35 | /*static char *sccsid = "from: @(#)strtoul.c 5.3 (Berkeley) 2/23/91";*/ |
| 36 | static char *rcsid = "$Id: strtoul.c,v 1.2 1995/12/21 14:58:38 deraadt Exp $"; | 36 | static char *rcsid = "$Id: strtoul.c,v 1.3 1996/07/27 10:45:25 deraadt Exp $"; |
| 37 | #endif /* LIBC_SCCS and not lint */ | 37 | #endif /* LIBC_SCCS and not lint */ |
| 38 | 38 | ||
| 39 | #include <ctype.h> | 39 | #include <ctype.h> |
| @@ -63,7 +63,7 @@ strtoul(nptr, endptr, base) | |||
| 63 | */ | 63 | */ |
| 64 | s = nptr; | 64 | s = nptr; |
| 65 | do { | 65 | do { |
| 66 | c = *s++; | 66 | c = (unsigned char) *s++; |
| 67 | } while (isspace(c)); | 67 | } while (isspace(c)); |
| 68 | if (c == '-') { | 68 | if (c == '-') { |
| 69 | neg = 1; | 69 | neg = 1; |
| @@ -84,7 +84,7 @@ strtoul(nptr, endptr, base) | |||
| 84 | 84 | ||
| 85 | cutoff = ULONG_MAX / (unsigned long)base; | 85 | cutoff = ULONG_MAX / (unsigned long)base; |
| 86 | cutlim = ULONG_MAX % (unsigned long)base; | 86 | cutlim = ULONG_MAX % (unsigned long)base; |
| 87 | for (acc = 0, any = 0;; c = *s++) { | 87 | for (acc = 0, any = 0;; c = (unsigned char) *s++) { |
| 88 | if (isdigit(c)) | 88 | if (isdigit(c)) |
| 89 | c -= '0'; | 89 | c -= '0'; |
| 90 | else if (isalpha(c)) | 90 | else if (isalpha(c)) |
