changeset 2326:54b4272de463

Silence compiler warnings (-Wformat-truncation, -Wstringop-truncation)
author Michał Kępień <bitbucket@kempniu.pl>
date Fri, 28 Sep 2018 06:45:58 +0200
parents c5665d3191aa
children 8ecc28068748
files mcabber/mcabber/commands.c mcabber/mcabber/screen.c
diffstat 2 files changed, 8 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/mcabber/mcabber/commands.c	Mon Sep 24 21:04:09 2018 +0200
+++ b/mcabber/mcabber/commands.c	Fri Sep 28 06:45:58 2018 +0200
@@ -1982,7 +1982,7 @@
         char tbuf[128];
 
         strftime(tbuf, sizeof(tbuf), "%Y-%m-%d %H:%M:%S", localtime(&rst_time));
-        snprintf(buffer, 127, "Status timestamp: %s", tbuf);
+        snprintf(buffer, 4095, "Status timestamp: %s", tbuf);
         scr_WriteIncomingMessage(bjid, buffer,
                                  0, HBB_PREFIX_INFO | HBB_PREFIX_CONT, 0);
       }
@@ -3166,7 +3166,7 @@
     char tbuf[128];
 
     strftime(tbuf, sizeof(tbuf), "%Y-%m-%d %H:%M:%S", localtime(&rst_time));
-    snprintf(buffer, 127, "Timestamp: %s", tbuf);
+    snprintf(buffer, 4095, "Timestamp: %s", tbuf);
     scr_WriteIncomingMessage(bjid, buffer, 0, msg_flag | HBB_PREFIX_CONT, 0);
   }
 
--- a/mcabber/mcabber/screen.c	Mon Sep 24 21:04:09 2018 +0200
+++ b/mcabber/mcabber/screen.c	Fri Sep 28 06:45:58 2018 +0200
@@ -4681,9 +4681,9 @@
         case 'j':
             if (isdigit((int)(unsigned char)inputLine[0]) &&
                 strlen(inputLine) <= 9) {
-              char down_cmd[32];
-              strncpy(down_cmd, mkcmdstr("roster down "), 32);
-              strncat(down_cmd, inputLine, 16);
+              char down_cmd[24];
+              snprintf (down_cmd, sizeof(down_cmd), "%.13s%.9s",
+                        mkcmdstr("roster down "), inputLine);
               process_command(down_cmd, TRUE);
             } else
               process_command(mkcmdstr("roster down"), TRUE);
@@ -4691,9 +4691,9 @@
         case 'k':
             if (isdigit((int)(unsigned char)inputLine[0]) &&
                 strlen(inputLine) <= 9) {
-              char up_cmd[32];
-              strncpy(up_cmd, mkcmdstr("roster up "), 32);
-              strncat(up_cmd, inputLine, 16);
+              char up_cmd[24];
+              snprintf (up_cmd, sizeof(up_cmd), "%.11s%.9s",
+                        mkcmdstr("roster up "), inputLine);
               process_command(up_cmd, TRUE);
             } else
               process_command(mkcmdstr("roster up "), TRUE);