[cpio] cpio: treat read() errors by checking for SAFE_READ_ERROR

Pavel Raiskup praiskup at fedoraproject.org
Sat May 24 08:39:36 UTC 2014


commit 088636f6aff1538e19fdcfe3d823730eaa6ee99e
Author: Pavel Raiskup <praiskup at redhat.com>
Date:   Sat May 24 10:38:02 2014 +0200

    cpio: treat read() errors by checking for SAFE_READ_ERROR
    
    Related: #996150
    Version: 2.11-27

 cpio-2.11-treat-read-errors.patch |   63 +++++++++++++------------------------
 cpio.spec                         |    8 +++-
 2 files changed, 28 insertions(+), 43 deletions(-)
---
diff --git a/cpio-2.11-treat-read-errors.patch b/cpio-2.11-treat-read-errors.patch
index a92922c..b15b8be 100644
--- a/cpio-2.11-treat-read-errors.patch
+++ b/cpio-2.11-treat-read-errors.patch
@@ -1,41 +1,22 @@
-commit 57288911a7882d663d6aa231158a3616f2ab2ed9
-Author:     Pavel Raiskup <praiskup at redhat.com>
-AuthorDate: Mon Sep 23 15:35:30 2013 +0200
-Commit:     Pavel Raiskup <praiskup at redhat.com>
-CommitDate: Mon Sep 23 16:42:11 2013 +0200
-
-    Use ssize_t for input buffer size
-    
-    Bug report: https://bugzilla.redhat.com/show_bug.cgi?id=996150
-    
-    * src/global.c: Use ssize_t rather than size_t for input_size.
-    * src/extern.h: Likewise.
-
-diff --git a/src/extern.h b/src/extern.h
-index ef00242..1e7193e 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 e08e188..a08006e 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;
- 
+diff --git a/src/util.c b/src/util.c
+index 00953d5..2a821c7 100644
+--- a/src/util.c
++++ b/src/util.c
+@@ -203,7 +203,7 @@ tape_fill_input_buffer (int in_des, int num_bytes)
+       get_next_reel (in_des);
+       input_size = rmtread (in_des, input_buffer, num_bytes);
+     }
+-  if (input_size < 0)
++  if (input_size == SAFE_READ_ERROR)
+     error (1, errno, _("read error"));
+   if (input_size == 0)
+     {
+@@ -224,7 +224,7 @@ disk_fill_input_buffer (int in_des, off_t num_bytes)
+   in_buff = input_buffer;
+   num_bytes = (num_bytes < DISK_IO_BLOCK_SIZE) ? num_bytes : DISK_IO_BLOCK_SIZE;
+   input_size = read (in_des, input_buffer, num_bytes);
+-  if (input_size < 0) 
++  if (input_size == SAFE_READ_ERROR)
+     {
+       input_size = 0;
+       return (-1);
diff --git a/cpio.spec b/cpio.spec
index b0dff58..838799c 100644
--- a/cpio.spec
+++ b/cpio.spec
@@ -1,7 +1,7 @@
 Summary: A GNU archiving program
 Name: cpio
 Version: 2.11
-Release: 26%{?dist}
+Release: 27%{?dist}
 License: GPLv3+
 Group: Applications/Archiving
 URL: http://www.gnu.org/software/cpio/
@@ -30,9 +30,10 @@ Patch8: cpio-2.11-crc-fips-nit.patch
 # ~> upstream
 Patch9: cpio-2.11-crc-large-files.patch
 
-# Allow treat read() errors by changing type of input_size to signed integer.
+# Allow treat read() errors by checking for SAFE_READ_ERROR
 # ~> downstream
 # ~> http://lists.gnu.org/archive/html/bug-cpio/2013-09/msg00005.html
+# ~> http://lists.gnu.org/archive/html/bug-cpio/2014-05/msg00001.html
 Patch10: cpio-2.11-treat-read-errors.patch
 
 # Small typo in RU translation
@@ -124,6 +125,9 @@ fi
 %{_infodir}/*.info*
 
 %changelog
+* Sat May 24 2014 Pavel Raiskup <praiskup at redhat.com> - 2.11-27
+- better fix for bad read() error checking (#996150)
+
 * Mon Apr 07 2014 Pavel Raiskup <praiskup at redhat.com> - 2.11-26
 - fix manual page to warn users about inode truncation (#952313)
 - fix for RU translation (#1075510)


More information about the scm-commits mailing list