This fix fixes the previous fix.

From: Robert Dubner <[email protected]>
Date: Sat, 11 Jul 2026 00:09:27 -0400
Subject: [PATCH] cobol: Use snprintf instead of strncpy in charmaps.cc.

This change eliminates compiler warnings about strncpy.

libgcobol/ChangeLog:

        * charmaps.cc (helpful_iconv_open): Use snprintf() instead of
strncpy().
---
 libgcobol/charmaps.cc | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/libgcobol/charmaps.cc b/libgcobol/charmaps.cc
index 1fdb9997c09..27f4b8f467d 100644
--- a/libgcobol/charmaps.cc
+++ b/libgcobol/charmaps.cc
@@ -1863,8 +1863,8 @@ helpful_iconv_open(const char *tocode, const char
*fromcode)
   char ach_to[32];
   char ach_from[32];
 
-  strncpy(ach_to, tocode, sizeof(ach_to)-1);
-  strncpy(ach_from, fromcode, sizeof(ach_from)-1);
+  snprintf(ach_to, sizeof ach_to, "%s", tocode);
+  snprintf(ach_from, sizeof ach_from, "%s", fromcode);
 
   fixcode(ach_to, sizeof(ach_to));
   fixcode(ach_from, sizeof(ach_from));
-- 
2.34.1

Reply via email to