Pārlūkot izejas kodu

libdpkg: Do not use an undefined va_list variable in dpkg_put_errno()

The va_start()/va_end() pair are surrounding the wrong function. This
might cause bogus error messages on some systems, or crashes on some
others depending on the stdarg implementation.
Guillem Jover 13 gadi atpakaļ
vecāks
revīzija
85ec281bf4
2 mainītis faili ar 4 papildinājumiem un 4 dzēšanām
  1. 1 0
      debian/changelog
  2. 3 4
      lib/dpkg/error.c

+ 1 - 0
debian/changelog

@@ -4,6 +4,7 @@ dpkg (1.16.10) UNRELEASED; urgency=low
   * Fix typos in 1.16.9 changelog entry. Closes: #691954
     Thanks to Nicolás Alvarez <nicolas.alvarez@gmail.com>.
   * Add missing @LIBLZMA_LIBS@ to Libs.Private in libdpkg.pc.in.
+  * Do not use an undefined va_list variable in dpkg_put_errno().
 
   [ Updated programs translations ]
   * Esperanto (Felipe Castro).

+ 3 - 4
lib/dpkg/error.c

@@ -71,13 +71,12 @@ dpkg_put_errno(struct dpkg_error *err, const char *fmt, ...)
 {
 	va_list args;
 	char *new_fmt;
-	int errno_saved = errno;
 
-	va_start(args, fmt);
-	m_asprintf(&new_fmt, "%s (%s)", fmt, strerror(errno_saved));
-	va_end(args);
+	m_asprintf(&new_fmt, "%s (%s)", fmt, strerror(errno));
 
+	va_start(args, fmt);
 	dpkg_error_set(err, DPKG_MSG_ERROR, new_fmt, args);
+	va_end(args);
 
 	free(new_fmt);