From e419521fb536d8d8811ba5f03ee30834a6c13c87 Mon Sep 17 00:00:00 2001 From: John Hodge Date: Sat, 10 May 2014 17:17:46 +0800 Subject: [PATCH 1/1] Usermode/libc - Actually fix strtoi (passing utest now) --- Usermode/Libraries/libc.so_src/strtoi.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Usermode/Libraries/libc.so_src/strtoi.c b/Usermode/Libraries/libc.so_src/strtoi.c index 9864fd57..84bf0005 100644 --- a/Usermode/Libraries/libc.so_src/strtoi.c +++ b/Usermode/Libraries/libc.so_src/strtoi.c @@ -138,7 +138,8 @@ long long strtoll(const char *str, char **end, int base) //_SysDebug("strtoll - neg=%i,ret=%llu", neg, ret); if( neg ) { - if( ret + LLONG_MIN > 0 ) { + // Abuses unsigned integer overflow + if( ret + LLONG_MIN < ret ) { errno = ERANGE; return LLONG_MIN; } -- 2.20.1