]> sjero.net Git - wget/commitdiff
[svn] Fix strtoll("0x", ptr, 0) to set *ptr to position of 'x', not after it.
authorhniksic <devnull@localhost>
Sat, 27 Aug 2005 19:27:46 +0000 (12:27 -0700)
committerhniksic <devnull@localhost>
Sat, 27 Aug 2005 19:27:46 +0000 (12:27 -0700)
src/ChangeLog
src/cmpt.c

index 43784484482e2ec778e6aadf18b4f3cabbac2eed..4ff935951f256f23cceae13de4e4b356c565802f 100644 (file)
@@ -1,3 +1,9 @@
+2005-08-27  Hrvoje Niksic  <hniksic@xemacs.org>
+
+       * cmpt.c (strtoll): Correctly handle strtoll("0x", ptr, 0) and
+       strtoll("0x<nonhexchar>", ptr, 0) -- in both cases *ptr must be
+       set to the position of 'x', not after it.
+
 2005-08-27  Hrvoje Niksic  <hniksic@xemacs.org>
 
        * hash.c (hash_table_map): Rename to hash_table_for_each and
index a41429512795cae0d718e57531afba98ebda8a57..03ff3ceb64d61b27e8008f170662014d942886b1 100644 (file)
@@ -1348,6 +1348,13 @@ strtoll (const char *nptr, char **endptr, int base)
        {
          base = 16;
          nptr += 2;
+         /* "0x" must be followed by at least one hex char.  If not,
+            return 0 and place ENDPTR on 'x'. */
+         if (!ISXDIGIT (*nptr))
+           {
+             --nptr;
+             goto out;
+           }
        }
       else if (base == 0)
        base = 8;
@@ -1387,6 +1394,7 @@ strtoll (const char *nptr, char **endptr, int base)
          result = newresult;
        }
     }
+ out:
   if (endptr)
     *endptr = (char *) nptr;
   return result;