erofs-utils: tar: return an error for invalid device numbers
PATCH 1/1 erofs-utils: tar: return an error for invalid device numbers
From: Zhan Xusheng <[email protected]>
If devmajor or devminor does not parse, tarerofs_parse_tar() jumps to out with ret still set to 512, the header size returned by erofs_iostream_read(). mkfs.erofs treats a positive return as the end of the archive, so it drops that entry and everything after it and exits with 0.
To reproduce, make a tar of a file "a", a character device whose devmajor is "00000x0", and files z0..z4, then run
mkfs.erofs --tar=f t.img x.tar
mkfs.erofs prints "invalid device major @ 1024", exits with 0, and the image only contains "a".
Return -EIO as for the other invalid header fields.
Fixes 95d315fd7958 ("erofs-utils: introduce tarerofs")
Signed-off-by Zhan Xusheng <[email protected]>
--- lib/tar.c | 2 ++ 1 file changed, 2 insertions(+)
lib/tar.c +2 -0
@@ -1047,12 +1047,14 @@ out_eot: major =tarerofs_parsenum (th->devmajor,sizeof (th->devmajor));if (errno) {erofs_err ("invalid device major @ %llu" , tar_offset); + ret = -EIO ; goto out; } minor =tarerofs_parsenum (th->devminor,sizeof (th->devminor));if (errno) {erofs_err ("invalid device minor @ %llu" , tar_offset); + ret = -EIO ; goto out; }
base-commit: 1114f15f3df938c1494553061e732b0a79a6463d
Signature · 1 line
2.43.0