Control: tags -1 + patch
Control: forwarded -1 https://github.com/TimothyPMann/xtrs/pull/25

The attached patch fixes the warning and allows building it
successfully.

Kind regards,
   Reiner
From e76e83104e4dc8d71c9ab3adcfd9aa512dbc7fd0 Mon Sep 17 00:00:00 2001
From: Reiner Herrmann <rei...@reiner-h.de>
Date: Mon, 6 Aug 2018 19:38:50 +0200
Subject: [PATCH] Use snprintf for string padding

Recent gcc versions emit new warnings about string truncation:

cmddump.c:78:7: error: 'strncat' output truncated copying between 0 and 8 bytes from a string of length 8 [-Werror=stringop-truncation]
       strncat(pdsbuf, "        ", 8 - strlen(pdsbuf));
       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

This can be prevented by using snprintf for string padding.

Bug-Debian: https://bugs.debian.org/905029
---
 cmddump.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/cmddump.c b/cmddump.c
index 174e72a..1b07bd8 100644
--- a/cmddump.c
+++ b/cmddump.c
@@ -76,9 +76,7 @@ main(int argc, char* argv[])
       isam = strtol(optarg, NULL, 0);
       break;
     case 'p':
-      strncpy(pdsbuf, optarg, 8);
-      pdsbuf[8] = '\000';
-      strncat(pdsbuf, "        ", 8 - strlen(pdsbuf));
+      snprintf(pdsbuf, sizeof(pdsbuf), "%s%8s", optarg, "");
       pds = pdsbuf;
       break;
     case 'x':
-- 
2.18.0

Attachment: signature.asc
Description: PGP signature

Reply via email to