I would like to propose a patch because after fix of CVE-2015-1197, cpio-2.14 set exit code to 2 when failing to create a symlink. In fact, in function copyin_link, cpio use symlink_error() instead of error() function.
From the user's perspective, exit code not equal to 0 means error and cpio should terminate, but cpio don't terminate. So I think
it's better to keep exit code as 0 when failing to create a symlink, which is consistent with cpio-2.13. I am very happy to hear any feedback or suggestions regarding this patch.
Hi cpio miantainers,
Before this commit, in copyin_link() function, when failing to create a symbolic link, cpio used error() to record failure. After this commit, cpio uses symlink_error () to record failure.
However, symlink_error() will set the exit code to 2 which means failure. May I know the reason for changing
error function to symlink_error function?
Below are the steps to reproduce the problem:
```
dd if=/dev/zero of=/root/tempfsvfat bs=1M count=4000
mkfs.vfat /root/tempfsvfat
mkdir vfat-file
mount tempfsvfat vfat-file/ # create a vfat file system which don't support symlink
cd vfat-file/
cp -ar /boot/initramfs-4.19.90-2109.1.0.0108.oe1.x86_64.img .
zcat *.img | cpio -di
echo $?
```
We may replace '/boot/initramfs-4.19.90-2109.1.0.0108.oe1.x86_64.img' file with any other initramfs file under /boot/ directory in Linux system.
The cpio will always fail to extract symbolic link under vfat-file directory which is normal behavior because vfat filesystem doesn't support symbolic link,
but the return value of 'echo $?' has changed from 0 to 2 when using the latest cpio version. In my opinion, cpio should terminate once it sets the exit code to 2
which means failure, but cpio didn't do that. So what is the expected exit code when failing to create a symbolic link?
Best
Ziyang