musl - musl - an implementation of the standard library for Linux-based systems

index : musl
musl - an implementation of the standard library for Linux-based systems
summary refs log tree commit diff
path: root/src/internal/intscan.c
diff options
context:
space:
mode:
authorRich Felker <dalias@aerifal.cx>2014年09月16日 16:08:53 -0400
committerRich Felker <dalias@aerifal.cx>2014年09月16日 16:08:53 -0400
commite2e1bb81485a37321d928a8d8b63f40b9d8fa228 (patch)
tree9b62eab14fa49e9a1f7cf9bc350a53d79eca60f0 /src/internal/intscan.c
parentec1aed0a144b3e00e16eeb142c9d13362d6048e7 (diff)
downloadmusl-e2e1bb81485a37321d928a8d8b63f40b9d8fa228.tar.gz
fix overflow corner case in strtoul-family functions
incorrect behavior occurred only in cases where the input overflows unsigned long long, not just the (possibly lower) range limit for the result type. in this case, processing of the '-' sign character was not suppressed, and the function returned a value of 1 despite setting errno to ERANGE.
Diffstat (limited to 'src/internal/intscan.c')
-rw-r--r--src/internal/intscan.c 1
1 files changed, 1 insertions, 0 deletions
diff --git a/src/internal/intscan.c b/src/internal/intscan.c
index 69350efa..65d497ec 100644
--- a/src/internal/intscan.c
+++ b/src/internal/intscan.c
@@ -83,6 +83,7 @@ unsigned long long __intscan(FILE *f, unsigned base, int pok, unsigned long long
for (; val[c]<base; c=shgetc(f));
errno = ERANGE;
y = lim;
+ if (lim&1) neg = 0;
}
done:
shunget(f);
generated by cgit v1.2.1 (git 2.18.0) at 2025年09月15日 16:51:53 +0000

AltStyle によって変換されたページ (->オリジナル) /