From: nekral-guest Date: Fri, 24 Apr 2009 22:27:58 +0000 (+0000) Subject: * libmisc/loginprompt.c: Prefer snprintf to sprintf, even if a X-Git-Tag: 4.1.4~96 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=42e72c418de321502cd8f13fc10bcd58626ece8b;p=shadow * libmisc/loginprompt.c: Prefer snprintf to sprintf, even if a small context indicates no issues. --- 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);