Pārlūkot izejas kodu

libdpkg: Only set error context message if it has been formatted correctly

We should not be adding junk to the error context message.
Guillem Jover 10 gadi atpakaļ
vecāks
revīzija
1d1c70fed1
2 mainītis faili ar 4 papildinājumiem un 1 dzēšanām
  1. 2 0
      debian/changelog
  2. 2 1
      lib/dpkg/ehandle.c

+ 2 - 0
debian/changelog

@@ -32,6 +32,8 @@ dpkg (1.18.11) UNRELEASED; urgency=medium
     standalone, by honoring SOURCE_DATE_EPOCH.
     standalone, by honoring SOURCE_DATE_EPOCH.
   * Fix several short-lived memory leaks in update-alternatives.
   * Fix several short-lived memory leaks in update-alternatives.
     Reported by Helmut Grohne <helmut@subdivi.de>.
     Reported by Helmut Grohne <helmut@subdivi.de>.
+  * Only set the error context message in libdpkg if it has been formatted
+    correctly.
   * Architecture support:
   * Architecture support:
     - Add support for AIX operating system.
     - Add support for AIX operating system.
   * Portability:
   * Portability:

+ 2 - 1
lib/dpkg/ehandle.c

@@ -195,7 +195,8 @@ error_context_errmsg_format(const char *fmt, va_list args)
 
 
   /* If the message was constructed successfully, at least we have some
   /* If the message was constructed successfully, at least we have some
    * error message, which is better than nothing. */
    * error message, which is better than nothing. */
-  error_context_errmsg_set(econtext, errmsg);
+  if (rc >= 0)
+    error_context_errmsg_set(econtext, errmsg);
 
 
   if (rc < 0) {
   if (rc < 0) {
     /* If there was any error, just use the emergency error message buffer,
     /* If there was any error, just use the emergency error message buffer,