diff -uNp -r cpio-2.10.90.old/lib/rtapelib.c cpio-2.10.90/lib/rtapelib.c --- cpio-2.10.90.old/lib/rtapelib.c 2009-06-18 16:07:51 +0000 +++ cpio-2.10.90/lib/rtapelib.c 2011-09-15 06:03:53.525222686 +0000 @@ -504,12 +504,14 @@ rmt_open__ (const char *file_name, int o /* Child. */ close (STDIN_FILENO); - dup (to_remote[remote_pipe_number][PREAD]); + if (dup (to_remote[remote_pipe_number][PREAD]) != STDIN_FILENO) + error (EXIT_ON_EXEC_ERROR, errno, _("Cannot dup")); close (to_remote[remote_pipe_number][PREAD]); close (to_remote[remote_pipe_number][PWRITE]); close (STDOUT_FILENO); - dup (from_remote[remote_pipe_number][PWRITE]); + if (dup (from_remote[remote_pipe_number][PWRITE]) != STDOUT_FILENO) + error (EXIT_ON_EXEC_ERROR, errno, _("Cannot dup")); close (from_remote[remote_pipe_number][PREAD]); close (from_remote[remote_pipe_number][PWRITE]); diff -uNp -r cpio-2.10.90.old/src/copyin.c cpio-2.10.90/src/copyin.c --- cpio-2.10.90.old/src/copyin.c 2011-09-15 06:03:21.775176098 +0000 +++ cpio-2.10.90/src/copyin.c 2011-09-15 06:11:12.365866297 +0000 @@ -539,8 +539,9 @@ copyin_regular_file (struct cpio_file_st "bug-gnu-utils@prep.ai.mit.edu". (96/7/10) -BEM */ if (delayed_seek_count > 0) { - lseek (out_file_des, delayed_seek_count-1, SEEK_CUR); - write (out_file_des, "", 1); + if (lseek (out_file_des, delayed_seek_count-1, SEEK_CUR) < 0 || + write (out_file_des, "", 1) != 1) + error (0, errno, _("cannot seek on output")); delayed_seek_count = 0; } @@ -1004,14 +1005,14 @@ from_ascii (char const *where, size_t di char *p = strchr (codetab, toupper (*buf)); if (!p) { - error (0, 0, _("Malformed number %.*s"), digs, where); + error (0, 0, _("Malformed number %.*s"), (unsigned) digs, where); break; } d = p - codetab; if ((d >> logbase) > 1) { - error (0, 0, _("Malformed number %.*s"), digs, where); + error (0, 0, _("Malformed number %.*s"), (unsigned) digs, where); break; } value += d; @@ -1022,7 +1023,7 @@ from_ascii (char const *where, size_t di } if (overflow) error (0, 0, _("Archive value %.*s is out of range"), - digs, where); + (unsigned) digs, where); return value; } diff -uNp -r cpio-2.10.90.old/src/copypass.c cpio-2.10.90/src/copypass.c --- cpio-2.10.90.old/src/copypass.c 2011-09-15 06:03:21.775176098 +0000 +++ cpio-2.10.90/src/copypass.c 2011-09-15 06:03:53.525222686 +0000 @@ -189,8 +189,9 @@ process_copy_pass () "bug-gnu-utils@prep.ai.mit.edu". (96/7/10) -BEM */ if (delayed_seek_count > 0) { - lseek (out_file_des, delayed_seek_count-1, SEEK_CUR); - write (out_file_des, "", 1); + if (lseek (out_file_des, delayed_seek_count-1, SEEK_CUR) < 0 || + write (out_file_des, "", 1) != 1) + error (0, errno, _("cannot seek on output")); delayed_seek_count = 0; } diff -uNp -r cpio-2.10.90.old/src/mt.c cpio-2.10.90/src/mt.c --- cpio-2.10.90.old/src/mt.c 2009-07-31 09:03:42 +0000 +++ cpio-2.10.90/src/mt.c 2011-09-15 06:11:12.365866297 +0000 @@ -207,7 +207,9 @@ parse_opt (int key, char *arg, struct ar { char *p; long val = strtol (arg, &p, 0); - if (*p || (count = val) != count) + int old_count = count; + count = val; + if (*p || count != old_count) error (MT_EXIT_INVOP, 0, _("invalid count value")); } break; diff -uNp -r cpio-2.10.90.old/src/util.c cpio-2.10.90/src/util.c --- cpio-2.10.90.old/src/util.c 2009-02-14 12:39:37 +0000 +++ cpio-2.10.90/src/util.c 2011-09-15 06:11:12.365866297 +0000 @@ -484,9 +484,9 @@ copy_files_disk_to_tape (int in_des, int while (num_bytes > 0) { if (input_size == 0) - if (rc = disk_fill_input_buffer (in_des, - num_bytes < DISK_IO_BLOCK_SIZE ? - num_bytes : DISK_IO_BLOCK_SIZE)) + if ((rc = disk_fill_input_buffer (in_des, + num_bytes < DISK_IO_BLOCK_SIZE ? + num_bytes : DISK_IO_BLOCK_SIZE))) { if (rc > 0) { @@ -499,7 +499,7 @@ copy_files_disk_to_tape (int in_des, int } else error (0, 0, _("Read error at byte %lld in file %s, padding with zeros"), - original_num_bytes - num_bytes, filename); + (long long)(original_num_bytes - num_bytes), filename); write_nuls_to_file (num_bytes, out_des, tape_buffered_write); break; } @@ -536,7 +536,7 @@ copy_files_disk_to_disk (int in_des, int while (num_bytes > 0) { if (input_size == 0) - if (rc = disk_fill_input_buffer (in_des, num_bytes)) + if ((rc = disk_fill_input_buffer (in_des, num_bytes))) { if (rc > 0) { @@ -549,7 +549,7 @@ copy_files_disk_to_disk (int in_des, int } else error (0, 0, _("Read error at byte %lld in file %s, padding with zeros"), - original_num_bytes - num_bytes, filename); + (long long)(original_num_bytes - num_bytes), filename); write_nuls_to_file (num_bytes, out_des, disk_buffered_write); break; } @@ -1165,7 +1165,8 @@ sparse_write (int fildes, char *buf, uns } else { - lseek (fildes, seek_count, SEEK_CUR); + if (lseek (fildes, seek_count, SEEK_CUR) == (off_t)-1) + return -1; cur_write_start = buf; write_count = DISKBLOCKSIZE; state = not_in_zeros; @@ -1176,7 +1177,8 @@ sparse_write (int fildes, char *buf, uns case not_in_zeros : if (buf_all_zeros (buf, DISKBLOCKSIZE)) { - write_rc = write (fildes, cur_write_start, write_count); + if (write (fildes, cur_write_start, write_count) != write_count) + return -1; seek_count = DISKBLOCKSIZE; state = in_zeros; } @@ -1197,7 +1199,8 @@ sparse_write (int fildes, char *buf, uns break; case not_in_zeros : - write_rc = write (fildes, cur_write_start, write_count); + if (write (fildes, cur_write_start, write_count) != write_count) + return -1; delayed_seek_count = 0; break; } @@ -1206,10 +1209,12 @@ sparse_write (int fildes, char *buf, uns { if (delayed_seek_count != 0) { - lseek_rc = lseek (fildes, delayed_seek_count, SEEK_CUR); + if (lseek (fildes, delayed_seek_count, SEEK_CUR) == (off_t)-1) + return -1; delayed_seek_count = 0; } - write_rc = write (fildes, buf, leftover_bytes_count); + if (write (fildes, buf, leftover_bytes_count) != leftover_bytes_count) + return -1; } return nbyte; } diff -uNp -r cpio-2.10.90.old/tests/genfile.c cpio-2.10.90/tests/genfile.c --- cpio-2.10.90.old/tests/genfile.c 2009-06-18 16:08:14 +0000 +++ cpio-2.10.90/tests/genfile.c 2011-09-15 06:03:53.525222686 +0000 @@ -478,7 +478,8 @@ mkhole (int fd, off_t displ) { if (lseek (fd, displ, SEEK_CUR) == -1) error (EXIT_FAILURE, errno, "lseek"); - ftruncate (fd, lseek (fd, 0, SEEK_CUR)); + if (ftruncate (fd, lseek (fd, 0, SEEK_CUR))) + error (EXIT_FAILURE, errno, "ftruncate"); } static void @@ -676,13 +677,15 @@ exec_checkpoint (struct action *p) error (0, errno, _("cannot open `%s'"), p->name); break; } - ftruncate (fd, p->size); + if (ftruncate (fd, p->size)) + error (0, errno, _("cannot truncate `%s'"), p->name); close (fd); } break; case OPT_EXEC: - system (p->name); + if (system (p->name) == -1) + error (0, errno, _("cannot execute `%s'"), p->name); break; default: @@ -741,7 +744,8 @@ exec_command (void) signal (SIGCHLD, SIG_DFL); #endif - pipe (fd); + if (pipe (fd)) + error (EXIT_FAILURE, errno, "pipe"); pid = fork (); if (pid == -1)