On Monday, September 23, 2013 17:31:45 Pavel Raiskup wrote: > [PATCH 1/2] Use ssize_t for input buffer size > > Fix for crash reported at https://bugzilla.redhat.com/996150 > > [PATCH 2/2] cpio: cleanup gcc -Wall warnings > > Just some cleanup.
Could we apply at least the first patch? That fixes not nice segfault caused by `find /sys | ./src/cpio -o > a.cpio`. That is caused because cpio is unable to handle negative error value from read(), look at: src/util.c:229: input_size = read (in_des, input_buffer, num_bytes); The second patch is not so important but it is usual to use -Wall option. So please consider. Both patches are re-attached reformatted against current HEAD. Pavel
>From 412f88758941e5ef285e06562efe4feb5908b5a2 Mon Sep 17 00:00:00 2001 From: Pavel Raiskup <[email protected]> Date: Mon, 23 Sep 2013 17:31:46 +0200 Subject: [PATCH 1/2] Use ssize_t for input buffer size * src/global.c: Use ssize_t rather than size_t for input_size. * src/extern.h: Likewise. References: http://lists.gnu.org/archive/html/bug-cpio/2013-09/msg00002.html https://bugzilla.redhat.com/996150 --- src/extern.h | 3 ++- src/global.c | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/extern.h b/src/extern.h index 92117cd..3eede33 100644 --- a/src/extern.h +++ b/src/extern.h @@ -83,7 +83,8 @@ extern int debug_flag; extern char *input_buffer, *output_buffer; extern char *in_buff, *out_buff; extern size_t input_buffer_size; -extern size_t input_size, output_size; +extern ssize_t input_size; +extern size_t output_size; extern off_t input_bytes, output_bytes; extern char *directory_name; diff --git a/src/global.c b/src/global.c index c699f6e..edc42d4 100644 --- a/src/global.c +++ b/src/global.c @@ -156,7 +156,8 @@ size_t input_buffer_size; char *in_buff, *out_buff; /* Current number of bytes stored at `input_buff' and `output_buff'. */ -size_t input_size, output_size; +ssize_t input_size; +size_t output_size; off_t input_bytes, output_bytes; -- 1.8.5.3
>From 0eea76a8eaf72c7ac092a645dbc805aa6c439b8f Mon Sep 17 00:00:00 2001 From: Pavel Raiskup <[email protected]> Date: Fri, 31 Jan 2014 08:25:51 +0100 Subject: [PATCH 2/2] cpio: cleanup gcc -Wall warnings * src/copyin.c (from_ascii): Use (int) for '*' printf modifier. * src/util.c: (copy_files_disk_to_tape): Use (long long int) for '%lld' modifier. (create_all_directories): Remove unused variable. --- src/copyin.c | 6 +++--- src/util.c | 14 ++++---------- 2 files changed, 7 insertions(+), 13 deletions(-) diff --git a/src/copyin.c b/src/copyin.c index 38d809f..22394ea 100644 --- a/src/copyin.c +++ b/src/copyin.c @@ -904,14 +904,14 @@ from_ascii (char const *where, size_t digs, unsigned logbase) char *p = strchr (codetab, toupper (*buf)); if (!p) { - error (0, 0, _("Malformed number %.*s"), digs, where); + error (0, 0, _("Malformed number %.*s"), (int)digs, where); break; } d = p - codetab; if ((d >> logbase) > 1) { - error (0, 0, _("Malformed number %.*s"), digs, where); + error (0, 0, _("Malformed number %.*s"), (int)digs, where); break; } value += d; @@ -922,7 +922,7 @@ from_ascii (char const *where, size_t digs, unsigned logbase) } if (overflow) error (0, 0, _("Archive value %.*s is out of range"), - digs, where); + (int)digs, where); return value; } diff --git a/src/util.c b/src/util.c index 18b3e42..dee441f 100644 --- a/src/util.c +++ b/src/util.c @@ -502,7 +502,7 @@ copy_files_disk_to_tape (int in_des, int out_des, off_t num_bytes, } else error (0, 0, _("Read error at byte %lld in file %s, padding with zeros"), - original_num_bytes - num_bytes, filename); + (long long int)original_num_bytes - num_bytes, filename); write_nuls_to_file (num_bytes, out_des, tape_buffered_write); break; } @@ -552,7 +552,7 @@ copy_files_disk_to_disk (int in_des, int out_des, off_t num_bytes, } else error (0, 0, _("Read error at byte %lld in file %s, padding with zeros"), - original_num_bytes - num_bytes, filename); + (long long int)original_num_bytes - num_bytes, filename); write_nuls_to_file (num_bytes, out_des, disk_buffered_write); break; } @@ -602,23 +602,17 @@ void create_all_directories (char *name) { char *dir; - int mode; #ifdef HPUX_CDF int cdf; #endif dir = dir_name (name); - mode = 0700; #ifdef HPUX_CDF cdf = islastparentcdf (name); if (cdf) - { - dir [strlen (dir) - 1] = '\0'; /* remove final + */ - mode = 04700; - } - + dir [strlen (dir) - 1] = '\0'; /* remove final + */ #endif - + if (dir == NULL) error (PAXEXIT_FAILURE, 0, _("virtual memory exhausted")); -- 1.8.5.3
