Просмотр исходного кода

libdpkg: Properly handle read errors on (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>
Signed-off-by: Guillem Jover <guillem@debian.org>
Jonathan Nieder лет назад: 16
Родитель
Сommit
5169de76c4
1 измененных файлов с 4 добавлено и 4 удалено
  1. 4 4
      lib/dpkg/compress.c

+ 4 - 4
lib/dpkg/compress.c

@@ -76,7 +76,7 @@ decompress_cat(enum compress_type type, int fd_in, int fd_out,
         char buffer[4096];
         int actualread;
         gzFile gzfile = gzdopen(fd_in, "r");
-        while ((actualread= gzread(gzfile,buffer,sizeof(buffer))) > 0) {
+        while ((actualread = gzread(gzfile, buffer, sizeof(buffer)))) {
           if (actualread < 0 ) {
             int err = 0;
             const char *errmsg = gzerror(gzfile, &err);
@@ -99,7 +99,7 @@ decompress_cat(enum compress_type type, int fd_in, int fd_out,
         char buffer[4096];
         int actualread;
         BZFILE *bzfile = BZ2_bzdopen(fd_in, "r");
-        while ((actualread= BZ2_bzread(bzfile,buffer,sizeof(buffer))) > 0) {
+        while ((actualread = BZ2_bzread(bzfile, buffer, sizeof(buffer)))) {
           if (actualread < 0 ) {
             int err = 0;
             const char *errmsg = BZ2_bzerror(bzfile, &err);
@@ -152,7 +152,7 @@ compress_cat(enum compress_type type, int fd_in, int fd_out,
         strncpy(combuf, "w9", sizeof(combuf));
         combuf[1]= *compression;
         gzfile = gzdopen(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;
             ohshite(_("%s: internal gzip read error"), v.buf);
@@ -185,7 +185,7 @@ compress_cat(enum compress_type type, int fd_in, int fd_out,
         strncpy(combuf, "w9", sizeof(combuf));
         combuf[1]= *compression;
         bzfile = BZ2_bzdopen(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;
             ohshite(_("%s: internal bzip2 read error"), v.buf);