static void
diff_multivol (void)
{
- struct stat stat_data;
- int fd, status;
- off_t offset;
-
if (current_stat_info.had_trailing_slash)
{
diff_dir ();
return;
}
+ struct stat stat_data;
if (!get_stat_data (current_stat_info.file_name, &stat_data))
return;
return;
}
- offset = OFF_FROM_HEADER (current_header->oldgnu_header.offset);
+ off_t offset = OFF_FROM_HEADER (current_header->oldgnu_header.offset);
+ off_t file_size;
if (offset < 0
- || INT_ADD_OVERFLOW (current_stat_info.stat.st_size, offset)
- || stat_data.st_size != current_stat_info.stat.st_size + offset)
+ || ckd_add (&file_size, current_stat_info.stat.st_size, offset)
+ || stat_data.st_size != file_size)
{
report_difference (¤t_stat_info, _("Size differs"));
skip_member ();
}
- fd = openat (chdir_fd, current_stat_info.file_name, open_read_flags);
+ int fd = openat (chdir_fd, current_stat_info.file_name, open_read_flags);
if (fd < 0)
{
else
read_and_process (¤t_stat_info, process_rawdata);
- status = close (fd);
- if (status != 0)
+ if (close (fd) < 0)
close_error (current_stat_info.file_name);
}
idx_t short_size = position0 % record_size;
idx_t start_offset = short_size ? record_size - short_size : 0;
off_t increment, move_start;
- if (INT_MULTIPLY_WRAPV (record_size, count, &increment)
- || INT_ADD_WRAPV (position0, start_offset, &move_start)
- || INT_ADD_WRAPV (move_start, increment, &position)
+ if (ckd_mul (&increment, record_size, count)
+ || ckd_add (&move_start, position0, start_offset)
+ || ckd_add (&position, move_start, increment)
|| position < 0)
{
ERROR ((0, EOVERFLOW, "lseek: %s", archive_name_array[0]));
return add_finish;
sp.offset = OFF_FROM_HEADER (s->offset);
sp.numbytes = OFF_FROM_HEADER (s->numbytes);
+ off_t size;
if (sp.offset < 0 || sp.numbytes < 0
- || INT_ADD_OVERFLOW (sp.offset, sp.numbytes)
- || file->stat_info->stat.st_size < sp.offset + sp.numbytes
+ || ckd_add (&size, sp.offset, sp.numbytes)
+ || file->stat_info->stat.st_size < size
|| file->stat_info->archive_file_size < 0)
return add_fail;
}
sp.offset = u;
COPY_BUF (blk,nbuf,p);
+ off_t size;
if (!decode_num (&u, nbuf, TYPE_MAXIMUM (off_t))
- || INT_ADD_OVERFLOW (sp.offset, u)
- || file->stat_info->stat.st_size < sp.offset + u)
+ || ckd_add (&size, sp.offset, u)
+ || file->stat_info->stat.st_size < size)
{
ERROR ((0, 0, _("%s: malformed sparse archive member"),
file->stat_info->orig_file_name));
? (count < 0 ? MTBSF : MTFSF)
: (count < 0 ? MTBSR : MTFSR));
if (! (count < 0
- ? INT_SUBTRACT_WRAPV (0, count, &operation.mt_count)
- : INT_ADD_WRAPV (count, 0, &operation.mt_count))
+ ? ckd_sub (&operation.mt_count, 0, count)
+ : ckd_add (&operation.mt_count, count, 0))
&& (0 <= rmtioctl (archive, MTIOCTOP, &operation)
|| (errno == EIO
&& 0 <= rmtioctl (archive, MTIOCTOP, &operation))))