Explorar o código

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 %!s(int64=13) %!d(string=hai) anos
pai
achega
85ec281bf4
Modificáronse 2 ficheiros con 4 adicións e 4 borrados
  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
   * Fix typos in 1.16.9 changelog entry. Closes: #691954
     Thanks to Nicolás Alvarez <nicolas.alvarez@gmail.com>.
     Thanks to Nicolás Alvarez <nicolas.alvarez@gmail.com>.
   * Add missing @LIBLZMA_LIBS@ to Libs.Private in libdpkg.pc.in.
   * 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 ]
   [ Updated programs translations ]
   * Esperanto (Felipe Castro).
   * 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;
 	va_list args;
 	char *new_fmt;
 	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);
 	dpkg_error_set(err, DPKG_MSG_ERROR, new_fmt, args);
+	va_end(args);
 
 
 	free(new_fmt);
 	free(new_fmt);