freebsd-src/bin/pax
Ganael Laplanche 681fd2bed8 pax: Terminate loop for empty directory names
Pax can sometimes loop forever. For example:

$ mkdir -p /tmp/src/foo/bar
$ rm -rf /tmp/dst ; mkdir -p /tmp/dst
$ cd /tmp/src
$ echo 'foo/bar/' | /bin/pax -r -w -d -pe "/tmp/dst"
<looping infinitely>

Here, pax(1) infinitely deletes and re-creates /tmp/dst/foo/bar/.

The problem is that chk_path() (bin/pax/file_subs.c), called from
node_creat() also creates the leaf directory when a trailing '/' appears
in the directory name to create. When the execution goes back from
chk_path() to node_creat(), the function still cannot create the leaf
directory (it has been created by chk_path()), so it unlinks it and
calls node_creat() again. The function re-creates it, and so on...

In node_creat() detect trailing slashes and not create a leaf directory,
but only intermediate ones.

PR: 277060
Reviewed by: imp
2024-06-21 10:39:09 -06:00
..
tests Remove $FreeBSD$: one-line sh pattern 2023-08-16 11:55:03 -06:00
ar_io.c bin: Automated cleanup of cdefs and other formatting 2023-11-26 22:23:59 -07:00
ar_subs.c bin: Automated cleanup of cdefs and other formatting 2023-11-26 22:23:59 -07:00
buf_subs.c bin: Automated cleanup of cdefs and other formatting 2023-11-26 22:23:59 -07:00
cache.c bin: Automated cleanup of cdefs and other formatting 2023-11-26 22:23:59 -07:00
cache.h bin: Remove ancient SCCS tags. 2023-11-26 22:23:28 -07:00
cpio.c bin: Automated cleanup of cdefs and other formatting 2023-11-26 22:23:59 -07:00
cpio.h bin: Remove ancient SCCS tags. 2023-11-26 22:23:28 -07:00
extern.h bin: Remove ancient SCCS tags. 2023-11-26 22:23:28 -07:00
file_subs.c pax: Terminate loop for empty directory names 2024-06-21 10:39:09 -06:00
ftree.c bin: Automated cleanup of cdefs and other formatting 2023-11-26 22:23:59 -07:00
ftree.h bin: Remove ancient SCCS tags. 2023-11-26 22:23:28 -07:00
gen_subs.c bin: Automated cleanup of cdefs and other formatting 2023-11-26 22:23:59 -07:00
getoldopt.c bin: Automated cleanup of cdefs and other formatting 2023-11-26 22:23:59 -07:00
Makefile bin: Remove ancient SCCS tags. 2023-11-26 22:23:28 -07:00
Makefile.depend Remove $FreeBSD$: one-line sh pattern 2023-08-16 11:55:03 -06:00
options.c bin: Automated cleanup of cdefs and other formatting 2023-11-26 22:23:59 -07:00
options.h bin: Remove ancient SCCS tags. 2023-11-26 22:23:28 -07:00
pat_rep.c bin: Automated cleanup of cdefs and other formatting 2023-11-26 22:23:59 -07:00
pat_rep.h bin: Remove ancient SCCS tags. 2023-11-26 22:23:28 -07:00
pax.1 bin: Remove ancient SCCS tags. 2023-11-26 22:23:28 -07:00
pax.c pax: Add missing 'for' in comment. 2023-12-26 10:24:24 -07:00
pax.h bin: Remove ancient SCCS tags. 2023-11-26 22:23:28 -07:00
sel_subs.c bin: Automated cleanup of cdefs and other formatting 2023-11-26 22:23:59 -07:00
sel_subs.h bin: Remove ancient SCCS tags. 2023-11-26 22:23:28 -07:00
tables.c bin: Automated cleanup of cdefs and other formatting 2023-11-26 22:23:59 -07:00
tables.h bin: Remove ancient SCCS tags. 2023-11-26 22:23:28 -07:00
tar.c bin: Automated cleanup of cdefs and other formatting 2023-11-26 22:23:59 -07:00
tar.h bin: Remove ancient SCCS tags. 2023-11-26 22:23:28 -07:00
tty_subs.c bin: Automated cleanup of cdefs and other formatting 2023-11-26 22:23:59 -07:00