[Reproducible-commits] [dpkg] 09/30: s-s-d: Use a heap allocated formatted string for what to stop
Mattia Rizzolo
mattia at debian.org
Mon May 9 09:02:50 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 6c9dbd427d085ce0bba878e294d1c8c20d1112cd
Author: Guillem Jover <guillem at debian.org>
Date: Fri May 6 01:15:38 2016 +0200
s-s-d: Use a heap allocated formatted string for what to stop
---
debian/changelog | 4 ++++
utils/start-stop-daemon.c | 29 ++++++++++++++++++-----------
2 files changed, 22 insertions(+), 11 deletions(-)
diff --git a/debian/changelog b/debian/changelog
index 654e40f..fb35d99 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -5,6 +5,10 @@ dpkg (1.18.7) UNRELEASED; urgency=medium
There is no point in erroring out on this condition when signature issues
are only warnings, because we cannot guarantee we have functional keys
for old signatures. Regression introduced in dpkg 1.18.5. Closes: #823428
+ * Stop using several fixed sized buffers for program reporting, which in
+ many cases could cause confusing truncation of long messages. Use heap
+ allocated formatted strings instead:
+ - In start-stop-daemon to report what to stop.
* Perl modules:
- Relax dependency restrictions parsing to allow again sloppy spaces
around versions, architectures and profile restrictions.
diff --git a/utils/start-stop-daemon.c b/utils/start-stop-daemon.c
index c2a81f4..479a129 100644
--- a/utils/start-stop-daemon.c
+++ b/utils/start-stop-daemon.c
@@ -200,7 +200,7 @@ static char *startas = NULL;
static pid_t match_pid = -1;
static pid_t match_ppid = -1;
static const char *pidfile = NULL;
-static char what_stop[1024];
+static char *what_stop = NULL;
static const char *progname = "";
static int nicelevel = 0;
static int umask_value = -1;
@@ -2159,11 +2159,18 @@ do_stop_summary(int retry_nr)
printf(".\n");
}
-static void
-set_what_stop(const char *str)
+static void DPKG_ATTR_PRINTF(1)
+set_what_stop(const char *format, ...)
{
- strncpy(what_stop, str, sizeof(what_stop));
- what_stop[sizeof(what_stop) - 1] = '\0';
+ va_list arglist;
+ int rc;
+
+ va_start(arglist, format);
+ rc = vasprintf(&what_stop, format, arglist);
+ va_end(arglist);
+
+ if (rc < 0)
+ fatal("cannot allocate formatted string");
}
/*
@@ -2262,17 +2269,17 @@ run_stop_schedule(void)
}
if (cmdname)
- set_what_stop(cmdname);
+ set_what_stop("%s", cmdname);
else if (execname)
- set_what_stop(execname);
+ set_what_stop("%s", execname);
else if (pidfile)
- sprintf(what_stop, "process in pidfile '%.200s'", pidfile);
+ set_what_stop("process in pidfile '%s'", pidfile);
else if (match_pid > 0)
- sprintf(what_stop, "process with pid %d", match_pid);
+ set_what_stop("process with pid %d", match_pid);
else if (match_ppid > 0)
- sprintf(what_stop, "process(es) with parent pid %d", match_ppid);
+ set_what_stop("process(es) with parent pid %d", match_ppid);
else if (userspec)
- sprintf(what_stop, "process(es) owned by '%.200s'", userspec);
+ set_what_stop("process(es) owned by '%s'", userspec);
else
fatal("internal error, no match option, please report");
--
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