From 1d1f55566570c678bf9f58dfb1a42f8a3e4bfb68 Mon Sep 17 00:00:00 2001 From: kib Date: Mon, 29 Apr 2013 21:12:25 +0000 Subject: 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 --- libexec/rtld-elf/rtld.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'libexec/rtld-elf/rtld.c') diff --git a/libexec/rtld-elf/rtld.c b/libexec/rtld-elf/rtld.c index 7a3938f..2da990c 100644 --- a/libexec/rtld-elf/rtld.c +++ b/libexec/rtld-elf/rtld.c @@ -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; -- cgit v1.1