[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

[PATCH v2 06/13] libdpkg: report read errors during (de)compression



Instead of using the error handling code, failed reads are being
treated as end of file.  This applies only when using zlib and
libbz2.  In practice it probably has not caused problems
because I/O errors are rare, and often the program at the other
end of the pipe can notice the pipe unexpectedly closing.

Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
---
 lib/dpkg/compression.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/lib/dpkg/compression.c b/lib/dpkg/compression.c
index f1b6836..31da38d 100644
--- a/lib/dpkg/compression.c
+++ b/lib/dpkg/compression.c
@@ -43,7 +43,7 @@ fd_fd_filter(int fd_in, int fd_out,
   int actualread; \
   zFile zfile = zdopen(fd_in, "r"); \
   \
-  while ((actualread = zread(zfile, buffer, sizeof(buffer))) > 0) { \
+  while ((actualread = zread(zfile, buffer, sizeof(buffer)))) { \
     if (actualread < 0) { \
       int err = 0; \
       const char *errmsg = zerror(zfile, &err); \
@@ -71,7 +71,7 @@ fd_fd_filter(int fd_in, int fd_out,
   strncpy(combuf, "w9", sizeof(combuf)); \
   combuf[1] = compression; \
   zfile = zdopen(fd_out, combuf); \
-  while ((actualread = read(fd_in, buffer, sizeof(buffer))) > 0) { \
+  while ((actualread = read(fd_in, buffer, sizeof(buffer)))) { \
     if (actualread < 0) { \
       if (errno == EINTR) \
         continue; \
-- 
1.6.5.rc1.199.g596ec


Reply to: