* src/list.c (read_header): Use ckd_add instead of
doing overflow checking by hand. Although the old code
was correct on all practical hosts, the new code is simpler
and works even on weird hosts where SIZE_MAX <= INT_MAX.
|| header->header.typeflag == GNUTYPE_LONGLINK)
{
union block *header_copy;
- size_t name_size = info->stat.st_size;
- size_t n = name_size % BLOCKSIZE;
- size = name_size + BLOCKSIZE;
- if (n)
- size += BLOCKSIZE - n;
-
- if (name_size != info->stat.st_size || size < name_size)
+ if (ckd_add (&size, info->stat.st_size, 2 * BLOCKSIZE - 1))
xalloc_die ();
+ size -= size % BLOCKSIZE;
header_copy = xmalloc (size + 1);