Usermode/libc - Actually fix strtoi (passing utest now)
authorJohn Hodge <[email protected]>
Sat, 10 May 2014 09:17:46 +0000 (17:17 +0800)
committerJohn Hodge <[email protected]>
Sat, 10 May 2014 09:17:46 +0000 (17:17 +0800)
Usermode/Libraries/libc.so_src/strtoi.c

index 9864fd5..84bf000 100644 (file)
@@ -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;
                }

UCC git Repository :: git.ucc.asn.au