mirror of
https://git.savannah.gnu.org/git/tar.git
synced 2026-04-22 01:20:43 +00:00
Cleaner overflow checking in xheader_read
* src/xheader.c (xheader_read): Prefer ckd_add to doing overflow checking by hand.
This commit is contained in:
@@ -783,12 +783,13 @@ xheader_read (struct xheader *xhdr, union block *p, off_t size)
|
||||
if (size < 0)
|
||||
size = 0; /* Already diagnosed. */
|
||||
|
||||
if (SIZE_MAX - BLOCKSIZE <= size)
|
||||
size_t size_plus_1;
|
||||
if (ckd_add (&size_plus_1, size, BLOCKSIZE + 1))
|
||||
xalloc_die ();
|
||||
size = size_plus_1 - 1;
|
||||
|
||||
size += BLOCKSIZE;
|
||||
xhdr->size = size;
|
||||
xhdr->buffer = xmalloc (size + 1);
|
||||
xhdr->buffer = xmalloc (size_plus_1);
|
||||
xhdr->buffer[size] = '\0';
|
||||
|
||||
do
|
||||
|
||||
Reference in New Issue
Block a user