erofs-utils: fsck: never follow exist symlinks when overwriting
PATCH 1/2 erofs-utils: fsck: never follow exist symlinks when overwriting
Otherwise, we could face potential security issues.
Fixes 412c8f908132 ("erofs-utils: fsck: add --extract=X support to extract to path X")
Signed-off-by Gao Xiang <[email protected]>
--- fsck/main.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
fsck/main.c +2 -2
@@ -496,8 +496,8 @@ static inline int erofs_extract_file(struct erofs_inode *inode) again: fd =open (fsckcfg.extract_path, -O_WRONLY |O_CREAT | (fsckcfg.overwrite ?O_TRUNC :O_EXCL ), -0700 ); +O_WRONLY |O_CREAT |O_NOFOLLOW | + (fsckcfg.overwrite ?O_TRUNC :O_EXCL ),0700 );if (fd <0 ) {if (fsckcfg.overwrite && tryagain) {if (errno ==EISDIR ) {
Signature · 1 line
2.24.4
PATCH 2/2 erofs-utils: fsck: don't set attributes when fscking only
Otherwise, when --extract is specified, it will report:
<W> erofs: erofsfsck_set_attributes() Line[189] failed to set times: (null) <W> erofs: erofsfsck_set_attributes() Line[197] failed to set permissions: (null)
...
Fixes 412c8f908132 ("erofs-utils: fsck: add --extract=X support to extract to path X")
Signed-off-by Gao Xiang <[email protected]>
--- fsck/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fsck/main.c +1 -1
@@ -665,7 +665,7 @@ verify: ret =erofs_iterate_dir (&ctx, true); } -if (!ret) +if (!ret && fsckcfg.extract_path)erofsfsck_set_attributes (&inode, fsckcfg.extract_path); out:
Signature · 1 line
2.24.4