gbranden pushed a commit to branch master
in repository groff.

commit 3c9bad3a6d7ed86b3acd563b43a1091ef5e58b82
Author: G. Branden Robinson <[email protected]>
AuthorDate: Wed Jun 24 21:25:38 2026 -0500

    [troff]: Fix -Wstringop-truncation warnings. (2/2)
    
    * src/roff/troff/input.cpp (init_charset_table): Use memcpy(3) instead
      of strncpy(3) because we're deliberately doing a partial write of a
      non-string `char` (byte) array into a buffer.
---
 ChangeLog                | 3 +++
 src/roff/troff/input.cpp | 4 ++--
 2 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 50ef411a8..4d5db0051 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -4,6 +4,9 @@
        warnings.
        (map_special_character_for_device_output): Don't overwrite the
        null terminator in the `character` buffer.
+       (init_charset_table): Use memcpy(3) instead of strncpy(3)
+       because we're deliberately doing a partial write of a non-string
+       `char` (byte) array into a buffer.
 
 2026-06-24  G. Branden Robinson <[email protected]>
 
diff --git a/src/roff/troff/input.cpp b/src/roff/troff/input.cpp
index 88e675772..31aa3aa6d 100644
--- a/src/roff/troff/input.cpp
+++ b/src/roff/troff/input.cpp
@@ -8720,8 +8720,8 @@ static const size_t char_prefix_len = sizeof char_prefix;
 
 static void init_charset_table()
 {
-  char buf[16];
-  (void) strncpy(buf, char_prefix, char_prefix_len);
+  char buf[16]; // XXX magic number
+  (void) memcpy(buf, char_prefix, char_prefix_len);
   for (int i = 0; i < 256; i++) {
     (void) strcpy((buf + char_prefix_len), i_to_a(i));
     charset_table[i] = lookup_charinfo(symbol(buf));

_______________________________________________
groff-commit mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/groff-commit

Reply via email to