[Reproducible-commits] [dpkg] 13/30: libdpkg: Do not use fixed size strings in reporting functions

Mattia Rizzolo mattia at debian.org
Mon May 9 09:02:51 UTC 2016


This is an automated email from the git hooks/post-receive script.

mattia pushed a commit to branch pu/reproducible_builds
in repository dpkg.

commit 99d596bf629c06d7b5d66825c4ca49141bbcc7e9
Author: Guillem Jover <guillem at debian.org>
Date:   Fri May 6 01:20:47 2016 +0200

    libdpkg: Do not use fixed size strings in reporting functions
---
 debian/changelog  |  1 +
 lib/dpkg/report.c | 20 ++++++++++++++------
 2 files changed, 15 insertions(+), 6 deletions(-)

diff --git a/debian/changelog b/debian/changelog
index e2185ca..4e794d6 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -11,6 +11,7 @@ dpkg (1.18.7) UNRELEASED; urgency=medium
     - 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.
+    - In libdpkg warning, notice and info reporting.
   * Perl modules:
     - Relax dependency restrictions parsing to allow again sloppy spaces
       around versions, architectures and profile restrictions.
diff --git a/lib/dpkg/report.c b/lib/dpkg/report.c
index b02e675..cbd8ecf 100644
--- a/lib/dpkg/report.c
+++ b/lib/dpkg/report.c
@@ -23,9 +23,11 @@
 #include <compat.h>
 
 #include <stdarg.h>
+#include <stdlib.h>
 #include <stdio.h>
 #include <unistd.h>
 
+#include <dpkg/dpkg.h>
 #include <dpkg/macros.h>
 #include <dpkg/i18n.h>
 #include <dpkg/progname.h>
@@ -60,13 +62,15 @@ warning_get_count(void)
 void
 warningv(const char *fmt, va_list args)
 {
-	char buf[1024];
+	char *buf = NULL;
 
 	warn_count++;
-	vsnprintf(buf, sizeof(buf), fmt, args);
+
+	m_vasprintf(&buf, fmt, args);
 	fprintf(stderr, "%s%s:%s %s%s:%s %s\n",
 	        color_get(COLOR_PROG), dpkg_get_progname(), color_reset(),
 	        color_get(COLOR_WARN), _("warning"), color_reset(), buf);
+	free(buf);
 }
 
 void
@@ -82,27 +86,31 @@ warning(const char *fmt, ...)
 void
 notice(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);
 
 	fprintf(stderr, "%s%s:%s %s\n",
 	        color_get(COLOR_PROG), dpkg_get_progname(), color_reset(), buf);
+
+	free(buf);
 }
 
 void
 info(const char *fmt, ...)
 {
-	char buf[1024];
+	char *buf;
 	va_list args;
 
 	va_start(args, fmt);
-	vsnprintf(buf, sizeof(buf), fmt, args);
+	m_vasprintf(&buf, fmt, args);
 	va_end(args);
 
 	printf("%s%s:%s %s\n",
 	       color_get(COLOR_PROG), dpkg_get_progname(), color_reset(), buf);
+
+	free(buf);
 }

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/reproducible/dpkg.git



More information about the Reproducible-commits mailing list