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

libdpkg: Fix error message from buffer_copy() read and write function

The buffer_read() and buffer_write() function error codes should have
higher precedence than a possible error from a truncated stream, otherwise
we will get confusing or just wrong error messages.

Regression introduced in commit ded3dfed77b7fd268914e19e8081b43c9233cc05.

Closes: #759498
Guillem Jover лет назад: 12
Родитель
Сommit
b851df1817
2 измененных файлов с 5 добавлено и 2 удалено
  1. 3 0
      debian/changelog
  2. 2 2
      lib/dpkg/buffer.c

+ 3 - 0
debian/changelog

@@ -49,6 +49,9 @@ dpkg (1.17.14) UNRELEASED; urgency=low
     - Add a new timeless feature, disabled by default, which will add
       «-Wdate-time» to CPPFLAGS.
     Thanks to Paul Wise <pabs@debian.org>. Closes: #762683
+  * Fix error message from buffer_copy() read and write functions. This
+    affects error messages from partial or broken .deb packages for example.
+    Regression introduced in dpkg 1.17.10. Closes: #759498
 
   [ Raphaël Hertzog ]
   * Explain better in deb-triggers(5) why interest/activate-noawait should be

+ 2 - 2
lib/dpkg/buffer.c

@@ -223,10 +223,10 @@ buffer_copy(struct buffer_data *read_data,
 
 	free(buf);
 
-	if (limit > 0)
-		return dpkg_put_error(err, _("unexpected end of file or stream"));
 	if (bytesread < 0 || byteswritten < 0)
 		return -1;
+	if (limit > 0)
+		return dpkg_put_error(err, _("unexpected end of file or stream"));
 
 	return totalread;
 }