Usermode/libc - Actually fix strtoi (passing utest now)
[tpg/acess2.git] / Usermode / Libraries / libc.so_src / strtoi.c
index 4fd2da5..84bf000 100644 (file)
@@ -12,7 +12,7 @@
 
 unsigned long long strtoull(const char *str, char **end, int base)
 {
-       long long       ret = 0;
+       unsigned long long      ret = 0;
        
        if( !str || base < 0 || base > 36 || base == 1 ) {
                if(end)
@@ -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 ) {
+               // Abuses unsigned integer overflow
+               if( ret + LLONG_MIN < ret ) {
                        errno = ERANGE;
                        return LLONG_MIN;
                }

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