svn commit: r250075 - head/libexec/rtld-elf

Konstantin Belousov kib at FreeBSD.org
Mon Apr 29 21:12:27 UTC 2013


Author: kib
Date: Mon Apr 29 21:12:25 2013
New Revision: 250075
URL: http://svnweb.freebsd.org/changeset/base/250075

Log:
  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

Modified:
  head/libexec/rtld-elf/rtld.c

Modified: head/libexec/rtld-elf/rtld.c
==============================================================================
--- head/libexec/rtld-elf/rtld.c	Mon Apr 29 21:12:18 2013	(r250074)
+++ head/libexec/rtld-elf/rtld.c	Mon Apr 29 21:12:25 2013	(r250075)
@@ -784,7 +784,7 @@ origin_subst_one(char *real, const char 
 	/*
 	 * 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 
 			/* Keyword replacement. */
 			memcpy(resp, subst, subst_len);
 			resp += subst_len;
+			*resp = '\0';
 			p = p1 + kw_len;
 		} else
 			break;


More information about the svn-src-head mailing list