From db63aefb211a4df84ac388ffa9b66e3add487351 Mon Sep 17 00:00:00 2001 From: "Todd C. Miller" Date: Thu, 25 Apr 2002 15:30:12 +0000 Subject: [PATCH] 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. --- check.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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); -- 2.50.1