From 42e72c418de321502cd8f13fc10bcd58626ece8b Mon Sep 17 00:00:00 2001 From: nekral-guest Date: Fri, 24 Apr 2009 22:27:58 +0000 Subject: [PATCH] * libmisc/loginprompt.c: Prefer snprintf to sprintf, even if a small context indicates no issues. --- ChangeLog | 5 +++++ libmisc/loginprompt.c | 5 +++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index b674c485..dc7c4307 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2009-04-25 Nicolas François + + * libmisc/loginprompt.c: Prefer snprintf to sprintf, even if a + small context indicates no issues. + 2009-04-25 Nicolas François * src/faillog.c: Remove function calls from within assert(). diff --git a/libmisc/loginprompt.c b/libmisc/loginprompt.c index 1d968d76..bcc42b36 100644 --- a/libmisc/loginprompt.c +++ b/libmisc/loginprompt.c @@ -156,8 +156,9 @@ void login_prompt (const char *prompt, char *name, int namesize) if (strchr (nvar, '=') != NULL) { envp[envc] = nvar; } else { - envp[envc] = xmalloc (strlen (nvar) + 32); - sprintf (envp[envc], "L%d=%s", count++, nvar); + size_t len = strlen (nvar) + 32; + envp[envc] = xmalloc (len); + snprintf (envp[envc], len, "L%d=%s", count++, nvar); } } set_env (envc, envp); -- 2.40.0