]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/commit
install(1): Fix relative path calculation with partial common dest/src
authorkevans <kevans@FreeBSD.org>
Thu, 31 Jan 2019 05:20:11 +0000 (05:20 +0000)
committerkevans <kevans@FreeBSD.org>
Thu, 31 Jan 2019 05:20:11 +0000 (05:20 +0000)
commit2e5f84858d5ce80f239f208ce9ee324ee9b9c6e6
tree39a272d2dc5a878f565b227553f2cc97f566cf92
parent3e5470bddfe85c2b406baa1c66999330a9bf87e6
install(1): Fix relative path calculation with partial common dest/src

For example, from the referenced PR [1]:

$ mkdir /tmp/lib/ /tmp/libexec
$ touch /tmp/lib/foo.so
$ install -lrs /tmp/lib/foo.so /tmp/libexec/

The common path identification bits terminate src at /tmp/lib/ and the
destination at /tmp/libe. The subsequent backtracking is then incorrect, as
it traverses the destination and backtraces exactly one level while eating
the 'libexec' because it was previously (falsely) identified as common with
'lib'.

The obvious fix would be to make sure we've actually terminated just after
directory separators and rewind a character if we haven't. In the above
example, we would end up rewinding to /tmp/ and subsequently doing the right
thing.

Test case added.

PR: 235330 [1]
MFC after: 1 week
usr.bin/xinstall/tests/install_test.sh
usr.bin/xinstall/xinstall.c