[PATCH] s6-log: Fix tainstamp being truncated

From: Olivier Brunel <jjk_at_jjacky.com>
Date: Sun, 8 Feb 2015 22:12:17 +0100

Signed-off-by: Olivier Brunel <jjk_at_jjacky.com>
---
TIMESTAMP is 25 char long, so just enough for the tainstamp with its _at_-prefix.
This was actually overwriting the last character in the tainstamp!
 src/daemontools-extras/s6-log.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/src/daemontools-extras/s6-log.c b/src/daemontools-extras/s6-log.c
index d460a90..8a5afc0 100644
--- a/src/daemontools-extras/s6-log.c
+++ b/src/daemontools-extras/s6-log.c
_at_@ -912,11 +912,11 @@ static void script_run (scriptelem_t const *script, unsigned int scriptlen, char
   int flagselected = 1, flagacted = 0 ;
   unsigned int i = 0, hlen = 0 ;
   char hstamp[32] ;
-  char tstamp[TIMESTAMP] ;
+  char tstamp[TIMESTAMP+1] ;
   if (gflags & 1)
   {
     timestamp_g(tstamp) ;
-    tstamp[TIMESTAMP-1] = ' ' ;
+    tstamp[TIMESTAMP] = ' ' ;
   }
   if (gflags & 2)
   {
_at_@ -953,7 +953,7 @@ static void script_run (scriptelem_t const *script, unsigned int scriptlen, char
       for (j = 0 ; j < script[i].actlen ; j++)
       {
         act_t const *act = script[i].acts + j ;
-        siovec_t v[4] = { { .s = tstamp, .len = act->flags & 1 ? TIMESTAMP : 0 }, { .s = hstamp, .len = act->flags & 2 ? hlen : 0 }, { .s = (char *)s, .len = len }, { .s = "\n", .len = 1 } } ;
+        siovec_t v[4] = { { .s = tstamp, .len = act->flags & 1 ? TIMESTAMP+1 : 0 }, { .s = hstamp, .len = act->flags & 2 ? hlen : 0 }, { .s = (char *)s, .len = len }, { .s = "\n", .len = 1 } } ;
         switch (act->type)
         {
           case ACTTYPE_FD1 :
-- 
2.3.0
Received on Sun Feb 08 2015 - 21:12:17 UTC

This archive was generated by hypermail 2.3.0 : Sun May 09 2021 - 19:38:49 UTC