From: Todd C. Miller Date: Thu, 25 Apr 2002 15:30:12 +0000 (+0000) Subject: The the loop used to expand %h and %u, the lastchar variable was not being X-Git-Tag: SUDO_1_6_6~3 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=db63aefb211a4df84ac388ffa9b66e3add487351;p=sudo The the loop used to expand %h and %u, the lastchar variable was not being initialized. This means that if the last char in the prompt is '%' and the first char is 'h' or 'u' a extra copy of the host or user name would be copied, for which space had not been allocated. --- diff --git a/check.c b/check.c index 5bb315086..837ad5b5a 100644 --- a/check.c +++ b/check.c @@ -196,9 +196,9 @@ expand_prompt(old_prompt, user, host) if (subst) { new_prompt = (char *) emalloc(len + 1); - for (p = old_prompt, np = new_prompt; *p; p++) { + for (p = old_prompt, np = new_prompt, lastchar = '\0'; *p; p++) { if (lastchar == '%' && (*p == 'h' || *p == 'u' || *p == '%')) { - /* substiture user/host name */ + /* substitute user/host name */ if (*p == 'h') { np--; strcpy(np, user_shost);