]> Savannah Git Hosting - gnulib.git/commitdiff
xstrtol: Strengthen sanity check.
authorAlejandro Colomar <alx@kernel.org>
Thu, 18 Jul 2024 17:58:55 +0000 (19:58 +0200)
committerBruno Haible <bruno@clisp.org>
Thu, 18 Jul 2024 17:58:55 +0000 (19:58 +0200)
* lib/xstrtol.c (__xstrtol): Don't allow strtol_base to be 1.

Copyright-paperwork-exempt: Yes

ChangeLog
lib/xstrtol.c

index 69a4afdb5f442fa684f676d0c875e83dedc22c9f..ee73f00cc8950748139377086ebd80090f946172 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2024-07-18  Alejandro Colomar  <alx@kernel.org>
+
+       xstrtol: Strengthen sanity check.
+       * lib/xstrtol.c (__xstrtol): Don't allow strtol_base to be 1.
+
 2024-07-18  Bruno Haible  <bruno@clisp.org>
 
        doc: Document the stack-trace and abort-debug modules.
index e4bce436813f13306c47d20555679480a3fe5363..575c16d45f9057b424b3788da55c80ae7f83c5b5 100644 (file)
@@ -83,7 +83,7 @@ __xstrtol (const char *s, char **ptr, int strtol_base,
   __strtol_t tmp;
   strtol_error err = LONGINT_OK;
 
-  assure (0 <= strtol_base && strtol_base <= 36);
+  assure (0 == strtol_base || (2 <= strtol_base && strtol_base <= 36));
 
   p = (ptr ? ptr : &t_ptr);