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

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



Hi!

On Sat, 2009-10-24 at 17:44:25 -0500, Jonathan Nieder wrote:
> 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.

> 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; \

Nice catch too! Applied.

thanks,
guillem


Reply to: