Properly terminate the result string for intermediate results, to
allow the final strcpy() to start at the intended place. Reported and tested by: pgj Pointy hat to: kib MFC after: 3 days
This commit is contained in:
parent
5c6fe3a917
commit
3c9cb0c6c9
@ -784,7 +784,7 @@ origin_subst_one(char *real, const char *kw, const char *subst,
|
||||
/*
|
||||
* Now, execute the substitution loop.
|
||||
*/
|
||||
for (p = real, resp = res;;) {
|
||||
for (p = real, resp = res, *resp = '\0';;) {
|
||||
p1 = strstr(p, kw);
|
||||
if (p1 != NULL) {
|
||||
/* Copy the prefix before keyword. */
|
||||
@ -793,6 +793,7 @@ origin_subst_one(char *real, const char *kw, const char *subst,
|
||||
/* Keyword replacement. */
|
||||
memcpy(resp, subst, subst_len);
|
||||
resp += subst_len;
|
||||
*resp = '\0';
|
||||
p = p1 + kw_len;
|
||||
} else
|
||||
break;
|
||||
|
Loading…
x
Reference in New Issue
Block a user