diff options
author | kib <kib@FreeBSD.org> | 2013-04-29 21:12:25 +0000 |
---|---|---|
committer | kib <kib@FreeBSD.org> | 2013-04-29 21:12:25 +0000 |
commit | 1d1f55566570c678bf9f58dfb1a42f8a3e4bfb68 (patch) | |
tree | a1b0e2ef4e4927910da9c1f7c3981d66c7631ae3 /libexec | |
parent | baeb59f05a9b972abc208ef0ded5c6c1d3983581 (diff) | |
download | FreeBSD-src-1d1f55566570c678bf9f58dfb1a42f8a3e4bfb68.zip FreeBSD-src-1d1f55566570c678bf9f58dfb1a42f8a3e4bfb68.tar.gz |
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
Diffstat (limited to 'libexec')
-rw-r--r-- | libexec/rtld-elf/rtld.c | 3 |
1 files changed, 2 insertions, 1 deletions
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; |