rtld: Sync 4/7 - Fix token substitution
authorJohn Marino <draco@marino.st>
Wed, 12 Jun 2013 12:24:28 +0000 (14:24 +0200)
committerJohn Marino <draco@marino.st>
Thu, 13 Jun 2013 11:12:07 +0000 (13:12 +0200)
commitda404cb4ad58fa4443ec9a94a036420276919b79
tree41ffbda5b88abbede20b396f077c8a4bd2c9e2e8
parente38c62d68d2615ea8761cb40a62bdbe751ca7751
rtld: Sync 4/7 - Fix token substitution

The origin_subst_one() function limits the length of the string to
PATH_MAX after the token substitution.  This is wrong, because
origin_subst_one() performs the substitution on the whole rpath and
similar strings, which contain several pathes separated by colon.  As
result, a long (but correct) rpath consisting of many path elements is
rejected by the function.

Correct the problem by rewriting the origin_subst_one() to perform two
passes, first pass to calculate the number of substitutions to be
performed, and second pass to generate the resulting string.  Second
pass allocates the memory for the result based on the count from the
first pass, without enforcing a limit.

Taken verbatim from:
FreeBSD SVN 249525 (15 APR 2013)
FreeBSD SVN 250075 (29 APR 2013)
libexec/rtld-elf/rtld.c