From bcd1d5304a76609feda859c6ed65076a525f9484 Mon Sep 17 00:00:00 2001 From: Ben Harris Date: Thu, 13 Mar 2025 13:49:43 +0000 Subject: [PATCH] Replace the one use of sprintf() with snprintf() It only acts on constant strings, so it can't actually overflow, but this way I can assert() that it really doesn't. --- bedstead.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/bedstead.c b/bedstead.c index a875585..d524564 100644 --- a/bedstead.c +++ b/bedstead.c @@ -3108,8 +3108,11 @@ get_fullname(void) { #define FULLNAME_MAX 100 static char fullname[FULLNAME_MAX]; + int len; - sprintf(fullname, FAMILY_NAME "%s%s", weight->suffix, width->suffix); + len = snprintf(fullname, sizeof(fullname), + FAMILY_NAME "%s%s", weight->suffix, width->suffix); + assert(len >= 0 && (unsigned)len < sizeof(fullname)); return fullname; } -- 2.30.2