fix previous patch (writeOutHeaderBufferOverflow)

This commit is contained in:
Peter Vrabec 2005-11-24 12:36:51 +00:00
parent 1d521775bd
commit 3554935953
2 changed files with 26 additions and 24 deletions

View File

@ -1,16 +1,5 @@
--- cpio-2.6/src/extern.h.backup 2005-11-15 13:30:46.000000000 -0500 --- cpio-2.6/src/copyout.c.bufferOverflow 2005-11-23 16:51:56.000000000 -0500
+++ cpio-2.6/src/extern.h 2005-11-15 13:31:12.000000000 -0500 +++ cpio-2.6/src/copyout.c 2005-11-23 17:00:38.000000000 -0500
@@ -112,7 +112,7 @@
void print_name_with_quoting P_((char *p));
/* copyout.c */
-void write_out_header P_((struct new_cpio_header *file_hdr, int out_des));
+int write_out_header P_((struct new_cpio_header *file_hdr, int out_des));
void process_copy_out P_((void));
/* copypass.c */
--- cpio-2.6/src/copyout.c.backup 2005-11-15 11:26:24.000000000 -0500
+++ cpio-2.6/src/copyout.c 2005-11-15 13:24:36.000000000 -0500
@@ -159,7 +159,7 @@ @@ -159,7 +159,7 @@
} }
@ -82,8 +71,7 @@
+to_ascii_or_warn (char *where, uintmax_t n, size_t digits, +to_ascii_or_warn (char *where, uintmax_t n, size_t digits,
+ unsigned logbase, + unsigned logbase,
+ const char *filename, const char *fieldname) + const char *filename, const char *fieldname)
{ +{
- if (archive_format == arf_newascii || archive_format == arf_crcascii)
+ if (to_ascii (where, n, digits, logbase)) + if (to_ascii (where, n, digits, logbase))
+ field_width_warning (filename, fieldname); + field_width_warning (filename, fieldname);
+} +}
@ -92,7 +80,8 @@
+to_ascii_or_error (char *where, uintmax_t n, size_t digits, +to_ascii_or_error (char *where, uintmax_t n, size_t digits,
+ unsigned logbase, + unsigned logbase,
+ const char *filename, const char *fieldname) + const char *filename, const char *fieldname)
+{ {
- if (archive_format == arf_newascii || archive_format == arf_crcascii)
+ if (to_ascii (where, n, digits, logbase)) + if (to_ascii (where, n, digits, logbase))
{ {
- char ascii_header[112]; - char ascii_header[112];
@ -487,18 +476,17 @@
/* Copy the named file to the output. */ /* Copy the named file to the output. */
switch (file_hdr.c_mode & CP_IFMT) switch (file_hdr.c_mode & CP_IFMT)
{ {
@@ -613,8 +766,8 @@ @@ -613,7 +766,8 @@
file_hdr.c_dev_min))) file_hdr.c_dev_min)))
{ {
file_hdr.c_tar_linkname = otherfile; file_hdr.c_tar_linkname = otherfile;
- write_out_header (&file_hdr, out_file_des); - write_out_header (&file_hdr, out_file_des);
- break;
+ if (write_out_header (&file_hdr, out_file_des)) + if (write_out_header (&file_hdr, out_file_des))
+ continue; + continue;
break;
} }
} }
if ( (archive_format == arf_newascii || archive_format == arf_crcascii) @@ -643,7 +797,8 @@
@@ -643,7 +796,8 @@
file_hdr.c_filesize, file_hdr.c_filesize,
input_name.ds_string); input_name.ds_string);
@ -508,7 +496,7 @@
copy_files_disk_to_tape (in_file_des, out_file_des, file_hdr.c_filesize, input_name.ds_string); copy_files_disk_to_tape (in_file_des, out_file_des, file_hdr.c_filesize, input_name.ds_string);
warn_if_file_changed(input_name.ds_string, file_hdr.c_filesize, warn_if_file_changed(input_name.ds_string, file_hdr.c_filesize,
file_hdr.c_mtime); file_hdr.c_mtime);
@@ -673,7 +827,8 @@ @@ -673,7 +828,8 @@
case CP_IFDIR: case CP_IFDIR:
file_hdr.c_filesize = 0; file_hdr.c_filesize = 0;
@ -518,7 +506,7 @@
break; break;
case CP_IFCHR: case CP_IFCHR:
@@ -702,14 +857,16 @@ @@ -702,14 +858,16 @@
file_hdr.c_mode = (file_stat.st_mode & 07777); file_hdr.c_mode = (file_stat.st_mode & 07777);
file_hdr.c_mode |= CP_IFREG; file_hdr.c_mode |= CP_IFREG;
file_hdr.c_tar_linkname = otherfile; file_hdr.c_tar_linkname = otherfile;
@ -537,7 +525,7 @@
break; break;
#ifdef CP_IFLNK #ifdef CP_IFLNK
@@ -738,12 +895,14 @@ @@ -738,12 +896,14 @@
{ {
link_name[link_size] = '\0'; link_name[link_size] = '\0';
file_hdr.c_tar_linkname = link_name; file_hdr.c_tar_linkname = link_name;
@ -554,3 +542,14 @@
tape_buffered_write (link_name, out_file_des, link_size); tape_buffered_write (link_name, out_file_des, link_size);
tape_pad_output (out_file_des, link_size); tape_pad_output (out_file_des, link_size);
} }
--- cpio-2.6/src/extern.h.bufferOverflow 2005-11-23 16:51:56.000000000 -0500
+++ cpio-2.6/src/extern.h 2005-11-23 16:51:56.000000000 -0500
@@ -112,7 +112,7 @@
void print_name_with_quoting P_((char *p));
/* copyout.c */
-void write_out_header P_((struct new_cpio_header *file_hdr, int out_des));
+int write_out_header P_((struct new_cpio_header *file_hdr, int out_des));
void process_copy_out P_((void));
/* copypass.c */

View File

@ -6,7 +6,7 @@
Summary: A GNU archiving program. Summary: A GNU archiving program.
Name: cpio Name: cpio
Version: 2.6 Version: 2.6
Release: 10 Release: 11
License: GPL License: GPL
Group: Applications/Archiving Group: Applications/Archiving
URL: http://www.gnu.org/software/cpio/ URL: http://www.gnu.org/software/cpio/
@ -105,6 +105,9 @@ fi
%{_infodir}/*.info* %{_infodir}/*.info*
%changelog %changelog
* Wed Nov 23 2005 Peter Vrabec <pvrabec@redhat.com> 2.6-11
- fix previous patch(writeOutHeaderBufferOverflow)
* Wed Nov 23 2005 Peter Vrabec <pvrabec@redhat.com> 2.6-10 * Wed Nov 23 2005 Peter Vrabec <pvrabec@redhat.com> 2.6-10
- write_out_header rewritten to fix buffer overflow(#172669) - write_out_header rewritten to fix buffer overflow(#172669)