gbranden pushed a commit to branch master
in repository groff.
commit 65d0a6b9c31aee141fc440c8c5c13fb6bcc7a489
Author: G. Branden Robinson <[email protected]>
AuthorDate: Wed Jun 24 21:15:19 2026 -0500
[troff]: Fix -Wstringop-truncation warnings. (1/2)
* src/roff/troff/input.cpp (map_special_character_for_device_output):
Don't overwrite the null terminator in the `character` buffer.
---
ChangeLog | 7 +++++++
src/roff/troff/input.cpp | 4 ++--
2 files changed, 9 insertions(+), 2 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 1d1abd009..50ef411a8 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2026-06-24 G. Branden Robinson <[email protected]>
+
+ * src/roff/troff/input.cpp: Fix `-Wstringop-truncation`
+ warnings.
+ (map_special_character_for_device_output): Don't overwrite the
+ null terminator in the `character` buffer.
+
2026-06-24 G. Branden Robinson <[email protected]>
* src/roff/troff/input.cpp
diff --git a/src/roff/troff/input.cpp b/src/roff/troff/input.cpp
index 921c3c89a..88e675772 100644
--- a/src/roff/troff/input.cpp
+++ b/src/roff/troff/input.cpp
@@ -6829,7 +6829,7 @@ static void map_special_character_for_device_output(macro
*mac,
if ((strlen(sc) < 3) || (sc[0] != 'u')) {
const char *un = glyph_name_to_unicode(sc);
if (un != 0 /* nullptr */)
- strncpy(character, un, sizeof character);
+ strncpy(character, un, (sizeof character - 1));
else {
warning(WARN_CHAR, "special character '%1' is not encodable"
" in device-independent output", sc);
@@ -6843,7 +6843,7 @@ static void map_special_character_for_device_output(macro
*mac,
" in device-independent output: %2", sc, errbuf);
return;
}
- strncpy(character, un, sizeof character);
+ strncpy(character, un, (sizeof character - 1));
}
mac->append_str("\\[u");
mac->append_str(character);
_______________________________________________
groff-commit mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/groff-commit