mirror of
https://git.savannah.gnu.org/git/tar.git
synced 2026-04-21 00:50:38 +00:00
Use ckd_mul, ckd_add in from_header
* 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.
This commit is contained in:
@@ -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
|
||||
|
||||
12
src/list.c
12
src/list.c
@@ -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++;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user