]> git.ipfire.org Git - thirdparty/tar.git/commitdiff
Use ckd_mul, ckd_add in from_header
authorPaul Eggert <eggert@cs.ucla.edu>
Sat, 3 Aug 2024 05:13:20 +0000 (22:13 -0700)
committerPaul Eggert <eggert@cs.ucla.edu>
Sun, 4 Aug 2024 08:41:43 +0000 (01:41 -0700)
* src/common.h (LG_64): Remove; no longer used.
* src/list.c (from_header):
Use ckd_mul, ckd_add rather than doing it by hand.

src/common.h
src/list.c

index 0120bf463c2b2114693bb4a7e4ec8dd6b1e8fef8..8a22c2ba716c75c9097cc3c8f5c1b2fd918fd876 100644 (file)
@@ -64,7 +64,6 @@
 
 /* Log base 2 of common values.  */
 #define LG_8 3
-#define LG_64 6
 #define LG_256 8
 
 _GL_INLINE_HEADER_BEGIN
index 339a650b3a9f2f1b8f8422a0e9ca6cdf698e0b31..6133b0c7051efc8d52c37591208f6ef50247da56 100644 (file)
@@ -793,7 +793,7 @@ from_header (char const *where0, size_t digs, char const *type,
          /* Compute the negative of the input value, assuming two's
             complement.  */
          int digit = (*where1 - '0') | 4;
-         overflow = 0;
+         overflow = false;
          value = 0;
          where = where1;
          for (;;)
@@ -803,11 +803,9 @@ from_header (char const *where0, size_t digs, char const *type,
              if (where == lim || ! is_octal_digit (*where))
                break;
              digit = *where - '0';
-             overflow |= value != (value << LG_8 >> LG_8);
-             value <<= LG_8;
+             overflow |= ckd_mul (&value, value, 8);
            }
-         value++;
-         overflow |= !value;
+         overflow |= ckd_add (&value, value, 1);
 
          if (!overflow && value <= minus_minval)
            {
@@ -853,7 +851,7 @@ from_header (char const *where0, size_t digs, char const *type,
       while (where != lim
             && (dig = base64_map[(unsigned char) *where]) < 64)
        {
-         if (value << LG_64 >> LG_64 != value)
+         if (ckd_mul (&value, value, 64))
            {
              if (type && !silent)
                ERROR ((0, 0,
@@ -861,7 +859,7 @@ from_header (char const *where0, size_t digs, char const *type,
                        quote_mem (where0, digs), type));
              return -1;
            }
-         value = (value << LG_64) | dig;
+         value |= dig;
          where++;
        }
     }