erofs-utils: fsck: fix fd leak on failure in erofs_extract_file()
PATCH 1/3 erofs-utils: fsck: fix fd leak on failure in erofs_extract_file()
Ignore the return values as other close()s instead.
Coverity-id: 502331
--- fsck/main.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
fsck/main.c +1 -3
@@ -702,11 +702,9 @@ again:/* verify data chunk layout */ ret =erofs_verify_inode_data (inode, fd); +close (fd);if (ret)return ret; - -if (close (fd)) -return -errno;return ret; }
Signature · 1 line
2.43.5
PATCH 2/3 erofs-utils: lib: fix out-of-bounds in erofs_io_xcopy()
Coverity-id: 502334
--- include/erofs/io.h | 4 ++-- lib/io.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-)
include/erofs/io.h +2 -2
@@ -34,7 +34,7 @@ struct erofs_vfops {off_t (*lseek)(struct erofs_vfile *vf,u64 offset,int whence);int (*fstat)(struct erofs_vfile *vf,struct stat *buf);int (*xcopy)(struct erofs_vfile *vout,off_t pos, -struct erofs_vfile *vin,int len,bool noseek); +struct erofs_vfile *vin,unsigned int len,bool noseek); };/* don't extend this; instead, use payload for any extra information */
@@ -61,7 +61,7 @@ off_t erofs_io_lseek(struct erofs_vfile *vf, u64 offset, int whence);ssize_t erofs_copy_file_range (int fd_in,u64 *off_in,int fd_out,u64 *off_out,size_t length);int erofs_io_xcopy (struct erofs_vfile *vout,off_t pos, -struct erofs_vfile *vin,int len,bool noseek); +struct erofs_vfile *vin,unsigned int len,bool noseek); #ifdef __cplusplus }
lib/io.c +2 -2
@@ -490,7 +490,7 @@ off_t erofs_io_lseek(struct erofs_vfile *vf, u64 offset, int whence) }int erofs_io_xcopy (struct erofs_vfile *vout,off_t pos, -struct erofs_vfile *vin,int len,bool noseek) +struct erofs_vfile *vin,unsigned int len,bool noseek) {if (vout->ops)return vout->ops->xcopy (vout, pos, vin, len, noseek);
@@ -519,7 +519,7 @@ int erofs_io_xcopy(struct erofs_vfile *vout, off_t pos, do { char buf[32768]; - int ret = min_t(int, len, sizeof(buf)); + int ret = min_t(unsigned int, len, sizeof(buf)); ret = erofs_io_read(vin, buf, ret); if (ret < 0)
Signature · 1 line
2.43.5
Re: [PATCH 2/3] erofs-utils: lib: fix out-of-bounds in erofs_io_xcopy()
Thanks,
Sandeep.
PATCH 3/3 erofs-utils: lib: fix fd leak on failure in erofs_dev_open()
In reply to Gao XiangCoverity-id: 502356
--- lib/io.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
lib/io.c +3 -1
@@ -258,8 +258,10 @@ repeat:#if defined(HAVE_SYS_STATFS_H ) && defined(HAVE_FSTATFS )struct statfs stfs; -if (again) +if (again) { +close (fd);return -ENOTEMPTY ; + }/* * fses like EXT4 and BTRFS will flush dirty blocks
Signature · 1 line
2.43.5
Re: [PATCH 3/3] erofs-utils: lib: fix fd leak on failure in erofs_dev_open()
Thanks,
Sandeep.
[PATCH 4/3] erofs-utils: lib: fix potential memory leak in erofs_export_xattr_ibody()
In reply to Gao XiangAlthough it won't happen in reality except for bugs.
Coverity-id: 507395
--- lib/xattr.c | 1 + 1 file changed, 1 insertion(+)
lib/xattr.c +1 -0
@@ -1020,6 +1020,7 @@ char *erofs_export_xattr_ibody(struct erofs_inode *inode)memset (buf + p,0 , size - p); }else if (__erofs_unlikely (p > size)) {DBG_BUGON (1 ); +free (buf);return ERR_PTR (-EFAULT ); }return buf;
Signature · 1 line
2.43.5
Sandeep Dhavale via Linux-erofs
Reviewed-by Sandeep DhavaleRe: [PATCH 4/3] erofs-utils: lib: fix potential memory leak in erofs_export_xattr_ibody()
Thanks,
Sandeep.
Hi Gao,
Quoted 14 lines · Gao Xiang
Ignore the return values as other close()s instead.
Coverity-id: 502331
Signed-off-by Gao Xiang <[email protected]>--- fsck/main.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)fsck/main.c +0
-0
fsck/main.c again: · line 707
Quoted 6 lines
fsck/main.c +1
-0@@ -702,11 +702,9 @@ again:/* verify data chunk layout */ ret =erofs_verify_inode_data (inode, fd); +close (fd);if (ret)return ret;
I think we can get rid of this if block and should be just return ret;
Quoted 9 lines
fsck/main.c +0
-4- -if (close (fd)) -return -errno;return ret; } --2.43.5
You can just do that while applying,
Thanks,
Sandeep.
Quoted 18 lines · Sandeep Dhavale via Linux-erofs
Hi Gao,
Quoted 15 lines · Gao Xiang
Ignore the return values as other close()s instead.
Coverity-id: 502331
Signed-off-by Gao Xiang <[email protected]>--- fsck/main.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)fsck/main.c +0
-0@@ -702,11 +702,9 @@ again:
Quoted 7 lines
fsck/main.c again: · line 707
Quoted 5 lines
fsck/main.c +1
-0/* verify data chunk layout */ ret =erofs_verify_inode_data (inode, fd); +close (fd);if (ret)return ret;I think we can get rid of this if block and should be just return ret;
Yeah, agreed, let me revise that.
Quoted 6 lines
Quoted 6 lines
fsck/main.c +0
-3- -if (close (fd)) -return -errno;return ret; }
Quoted 7 lines
Quoted 3 lines
--
2.43.5You can just do that while applying,
Reviewed-by Sandeep Dhavale <[email protected]>
Thanks for your review!
Thanks,
Gao Xiang
Quoted 2 lines
Thanks,
Sandeep.