Преглед изворни кода

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 година
родитељ
комит
1d1c70fed1
2 измењених фајлова са 4 додато и 1 уклоњено
  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.
   * Fix several short-lived memory leaks in update-alternatives.
     Reported by Helmut Grohne <helmut@subdivi.de>.
+  * Only set the error context message in libdpkg if it has been formatted
+    correctly.
   * Architecture support:
     - Add support for AIX operating system.
   * 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
    * 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 there was any error, just use the emergency error message buffer,