summaryrefslogtreecommitdiffstats
path: root/lib/libc/stdlib
diff options
context:
space:
mode:
Diffstat (limited to 'lib/libc/stdlib')
-rw-r--r--lib/libc/stdlib/strtoll.c4
-rw-r--r--lib/libc/stdlib/strtoq.c4
-rw-r--r--lib/libc/stdlib/strtoul.c4
-rw-r--r--lib/libc/stdlib/strtoull.c4
-rw-r--r--lib/libc/stdlib/strtouq.c4
5 files changed, 15 insertions, 5 deletions
diff --git a/lib/libc/stdlib/strtoll.c b/lib/libc/stdlib/strtoll.c
index b31cca4..a5720df 100644
--- a/lib/libc/stdlib/strtoll.c
+++ b/lib/libc/stdlib/strtoll.c
@@ -56,7 +56,7 @@ strtoq(nptr, endptr, base)
{
register const char *s;
register u_quad_t acc;
- register int c;
+ register unsigned char c;
register u_quad_t qbase, cutoff;
register int neg, any, cutlim;
@@ -109,6 +109,8 @@ strtoq(nptr, endptr, base)
cutlim = cutoff % qbase;
cutoff /= qbase;
for (acc = 0, any = 0;; c = *s++) {
+ if (!isascii(c))
+ break;
if (isdigit(c))
c -= '0';
else if (isalpha(c))
diff --git a/lib/libc/stdlib/strtoq.c b/lib/libc/stdlib/strtoq.c
index b31cca4..a5720df 100644
--- a/lib/libc/stdlib/strtoq.c
+++ b/lib/libc/stdlib/strtoq.c
@@ -56,7 +56,7 @@ strtoq(nptr, endptr, base)
{
register const char *s;
register u_quad_t acc;
- register int c;
+ register unsigned char c;
register u_quad_t qbase, cutoff;
register int neg, any, cutlim;
@@ -109,6 +109,8 @@ strtoq(nptr, endptr, base)
cutlim = cutoff % qbase;
cutoff /= qbase;
for (acc = 0, any = 0;; c = *s++) {
+ if (!isascii(c))
+ break;
if (isdigit(c))
c -= '0';
else if (isalpha(c))
diff --git a/lib/libc/stdlib/strtoul.c b/lib/libc/stdlib/strtoul.c
index e60556c0..0bf6b82 100644
--- a/lib/libc/stdlib/strtoul.c
+++ b/lib/libc/stdlib/strtoul.c
@@ -54,7 +54,7 @@ strtoul(nptr, endptr, base)
{
register const char *s = nptr;
register unsigned long acc;
- register int c;
+ register unsigned char c;
register unsigned long cutoff;
register int neg = 0, any, cutlim;
@@ -80,6 +80,8 @@ strtoul(nptr, endptr, base)
cutoff = (unsigned long)ULONG_MAX / (unsigned long)base;
cutlim = (unsigned long)ULONG_MAX % (unsigned long)base;
for (acc = 0, any = 0;; c = *s++) {
+ if (!isascii(c))
+ break;
if (isdigit(c))
c -= '0';
else if (isalpha(c))
diff --git a/lib/libc/stdlib/strtoull.c b/lib/libc/stdlib/strtoull.c
index ee1e13b..16dda0b 100644
--- a/lib/libc/stdlib/strtoull.c
+++ b/lib/libc/stdlib/strtoull.c
@@ -56,7 +56,7 @@ strtouq(nptr, endptr, base)
{
register const char *s = nptr;
register u_quad_t acc;
- register int c;
+ register unsigned char c;
register u_quad_t qbase, cutoff;
register int neg, any, cutlim;
@@ -87,6 +87,8 @@ strtouq(nptr, endptr, base)
cutoff = (u_quad_t)UQUAD_MAX / qbase;
cutlim = (u_quad_t)UQUAD_MAX % qbase;
for (acc = 0, any = 0;; c = *s++) {
+ if (!isascii(c))
+ break;
if (isdigit(c))
c -= '0';
else if (isalpha(c))
diff --git a/lib/libc/stdlib/strtouq.c b/lib/libc/stdlib/strtouq.c
index ee1e13b..16dda0b 100644
--- a/lib/libc/stdlib/strtouq.c
+++ b/lib/libc/stdlib/strtouq.c
@@ -56,7 +56,7 @@ strtouq(nptr, endptr, base)
{
register const char *s = nptr;
register u_quad_t acc;
- register int c;
+ register unsigned char c;
register u_quad_t qbase, cutoff;
register int neg, any, cutlim;
@@ -87,6 +87,8 @@ strtouq(nptr, endptr, base)
cutoff = (u_quad_t)UQUAD_MAX / qbase;
cutlim = (u_quad_t)UQUAD_MAX % qbase;
for (acc = 0, any = 0;; c = *s++) {
+ if (!isascii(c))
+ break;
if (isdigit(c))
c -= '0';
else if (isalpha(c))
OpenPOWER on IntegriCloud