소스 검색

continue reading in xz even if it outputs nothing

It can happen that content in our buffer is not enough to produce a
meaningful output in which case no output is created by liblzma, but
still reports that everything is okay and we should go on.

The code assumes it has reached the end through if it encounters a null
read, so this commit makes it so that it looks like this read was
interrupted just like the lowlevel read() on uncompressed files could.

It subsequently fixes the issue with that as well as until now our loop
would still break even if we wanted it to continue on.

(This bug triggers our usual "Hash sum mismatch" error)

Reported-By: Stefan Lippers-Hollmann <s.L-H@gmx.de>
David Kalnischkies 12 년 전
부모
커밋
c4b113e650
1개의 변경된 파일과 13개의 추가작업 그리고 0개의 파일을 삭제
  1. 13 0
      apt-pkg/contrib/fileutl.cc

+ 13 - 0
apt-pkg/contrib/fileutl.cc

@@ -1430,7 +1430,15 @@ bool FileFd::Read(void *To,unsigned long long Size,unsigned long long *Actual)
 	    errno = 0;
 	 }
 	 else
+	 {
 	    Res = Size - d->lzma->stream.avail_out;
+	    if (Res == 0)
+	    {
+	       // lzma run was okay, but produced no output…
+	       Res = -1;
+	       errno = EINTR;
+	    }
+	 }
       }
 #endif
       else
@@ -1439,7 +1447,12 @@ bool FileFd::Read(void *To,unsigned long long Size,unsigned long long *Actual)
       if (Res < 0)
       {
 	 if (errno == EINTR)
+	 {
+	    // trick the while-loop into running again
+	    Res = 1;
+	    errno = 0;
 	    continue;
+	 }
 	 if (false)
 	    /* dummy so that the rest can be 'else if's */;
 #ifdef HAVE_ZLIB