dcavalca / rpms / systemd

Forked from rpms/systemd 3 years ago
Clone
e046734
From 37c30b6829eabedf0e5c800aeffb16d4d1b3d2ec Mon Sep 17 00:00:00 2001
ed724b6
From: Lennart Poettering <lennart@poettering.net>
ed724b6
Date: Wed, 2 Nov 2016 12:02:53 -0600
ed724b6
Subject: [PATCH] core: don't hit an assert when printing status messages about
ed724b6
 units with overly long description strings
ed724b6
MIME-Version: 1.0
ed724b6
Content-Type: text/plain; charset=UTF-8
ed724b6
Content-Transfer-Encoding: 8bit
ed724b6
ed724b6
This essentially reverts one part of d054f0a4d451120c26494263fc4dc175bfd405b1.
ed724b6
ed724b6
(We might also choose to use proper ellipsation here, but I wasn't sure the
ed724b6
memory allocation this requires wouöld be a good idea here...)
ed724b6
ed724b6
Fixes: #4534
ed724b6
(cherry picked from commit 07ecca0dc9d2d8f3b3abd73ab32f254f339fd903)
ed724b6
---
ed724b6
 src/core/job.c | 3 ++-
ed724b6
 1 file changed, 2 insertions(+), 1 deletion(-)
ed724b6
ed724b6
diff --git a/src/core/job.c b/src/core/job.c
e046734
index 7557874d4d..4efcfb80f3 100644
ed724b6
--- a/src/core/job.c
ed724b6
+++ b/src/core/job.c
ed724b6
@@ -767,8 +767,9 @@ static void job_log_status_message(Unit *u, JobType t, JobResult result) {
ed724b6
         if (!format)
ed724b6
                 return;
ed724b6
 
ed724b6
+        /* The description might be longer than the buffer, but that's OK, we'll just truncate it here */
ed724b6
         DISABLE_WARNING_FORMAT_NONLITERAL;
ed724b6
-        xsprintf(buf, format, unit_description(u));
ed724b6
+        snprintf(buf, sizeof(buf), format, unit_description(u));
ed724b6
         REENABLE_WARNING;
ed724b6
 
ed724b6
         switch (t) {