]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/commit
MFC r343601:
authorkevans <kevans@FreeBSD.org>
Sat, 16 Feb 2019 04:49:10 +0000 (04:49 +0000)
committerkevans <kevans@FreeBSD.org>
Sat, 16 Feb 2019 04:49:10 +0000 (04:49 +0000)
commit1a542ccd3e6c706b8b4f10068681aeb8e64cb076
tree9b374b7d202c60d984382ef7f2d6edc8eecb1111
parentb6257adb450742074500290252ebfa4077e2ee79
MFC r343601:
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]
usr.bin/xinstall/tests/install_test.sh
usr.bin/xinstall/xinstall.c