Quellcode durchsuchen

libdpkg: Do not use fixed size buffers in options module

Guillem Jover vor 10 Jahren
Ursprung
Commit
5982d9503c
2 geänderte Dateien mit 5 neuen und 4 gelöschten Zeilen
  1. 1 0
      debian/changelog
  2. 4 4
      lib/dpkg/options.c

+ 1 - 0
debian/changelog

@@ -10,6 +10,7 @@ dpkg (1.18.7) UNRELEASED; urgency=medium
     allocated formatted strings instead:
     - In start-stop-daemon to report what to stop.
     - In dselect to print main and access methods menu entries.
+    - In libdpkg command-line option parsing errors.
   * Perl modules:
     - Relax dependency restrictions parsing to allow again sloppy spaces
       around versions, architectures and profile restrictions.

+ 4 - 4
lib/dpkg/options.c

@@ -41,11 +41,11 @@ static const char *printforhelp;
 void
 badusage(const char *fmt, ...)
 {
-  char buf[1024];
+  char *buf = NULL;
   va_list args;
 
   va_start(args, fmt);
-  vsnprintf(buf, sizeof(buf), fmt, args);
+  m_vasprintf(&buf, fmt, args);
   va_end(args);
 
   ohshit("%s\n\n%s", buf, gettext(printforhelp));
@@ -54,11 +54,11 @@ badusage(const char *fmt, ...)
 static void DPKG_ATTR_NORET DPKG_ATTR_PRINTF(3)
 config_error(const char *file_name, int line_num, const char *fmt, ...)
 {
-  char buf[1024];
+  char *buf = NULL;
   va_list args;
 
   va_start(args, fmt);
-  vsnprintf(buf, sizeof(buf), fmt, args);
+  m_vasprintf(&buf, fmt, args);
   va_end(args);
 
   ohshit(_("configuration error: %s:%d: %s"), file_name, line_num, buf);