xfsprogs: Fix some issues found by checker
cover xfsprogs: Fix some issues found by checker
Both issues have been found by Red Hat's covscan checker.
Pavel Reichl (2):
xfs_db: Fix uninicialized error variable
xfs_io: Fix do not loop through uninitialized var
db/hash.c | 2 +- io/parent.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-)
Signature · 1 line
2.45.1
PATCH 1/2 xfs_db: Fix uninicialized error variable
To silence redhat's covscan checker:
Error: UNINIT (CWE-457): [#def1] [important] xfsprogs-6.4.0/db/hash.c:308:2: var_decl: Declaring variable "error" without initializer. xfsprogs-6.4.0/db/hash.c:353:2: uninit_use: Using uninitialized value "error".
--- db/hash.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
db/hash.c +1 -1
@@ -304,7 +304,7 @@ collide_xattrs(struct dup_table *tab =NULL ;xfs_dahash_t old_hash;unsigned long i; -int error; +int error =0 ; old_hash =libxfs_da_hashname ((uint8_t *)name, namelen);
Signature · 1 line
2.45.1
Re: [PATCH 1/2] xfs_db: Fix uninicialized error variable
Quoted 7 lines · Pavel Reichl
To silence redhat's covscan checker:
Error: UNINIT (CWE-457): [#def1] [important]
xfsprogs-6.4.0/db/hash.c:308:2:var_decl: Declaring variable "error" without initializer.xfsprogs-6.4.0/db/hash.c:353:2:uninit_use: Using uninitialized value "error".Signed-off-by Pavel Reichl <[email protected]>
Looks good,
--D
Quoted 21 lines
--- db/hash.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)db/hash.c +1
-1@@ -304,7 +304,7 @@ collide_xattrs(struct dup_table *tab =NULL ;xfs_dahash_t old_hash;unsigned long i; -int error; +int error =0 ; old_hash =libxfs_da_hashname ((uint8_t *)name, namelen);Signature · 1 line
2.45.1
Re: [PATCH 1/2] xfs_db: Fix uninicialized error variable
In reply to Pavel ReichlLooks good:
PATCH 2/2 xfs_io: Fix do not loop through uninitialized var
In reply to Pavel ReichlRed Hat's covscan checker found the following issue:
xfsprogs-6.4.0/io/parent.c:115:2: var_decl: Declaring variable "count" without initializer. xfsprogs-6.4.0/io/parent.c:134:2: uninit_use: Using uninitialized value "count".
Currently, jdm_parentpaths() returns EOPNOTSUPP and does not initialize the count variable. The count variable is subsequently used in a for loop, which leads to undefined behavior. Fix this by returning from the check_parents() function immediately after checking the return value of the jdm_parentpaths() function.
--- io/parent.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
io/parent.c +2 -2
@@ -112,7 +112,7 @@ check_parents(parent_t *parentbuf, size_t *parentbuf_size, jdm_fshandle_t *fshandlep, struct xfs_bstat *statp) { int error, i; -__u32 count; +__u32 count =0 ;parent_t *entryp; do {
@@ -126,7 +126,7 @@ check_parents(parent_t *parentbuf, size_t *parentbuf_size, (unsigned long long ) statp->bs_ino, strerror(errno)); err_status++; -break ; +return ; } }while (error ==ERANGE );
Signature · 1 line
2.45.1
Re: [PATCH 2/2] xfs_io: Fix do not loop through uninitialized var
Quoted 5 lines · Pavel Reichl
Red Hat's covscan checker found the following issue:
xfsprogs-6.4.0/io/parent.c:115:2:var_decl: Declaring variable "count" without initializer.xfsprogs-6.4.0/io/parent.c:134:2:uninit_use: Using uninitialized value "count".
Quoted 7 lines
Currently,
jdm_parentpaths()returns EOPNOTSUPP and does not initialize the count variable. The count variable is subsequently used in a for loop, which leads to undefined behavior. Fix this by returning from thecheck_parents()function immediately after checking the return value of thejdm_parentpaths()function.Signed-off-by Pavel Reichl <[email protected]>
I'm waiting on Carlos to take the xfsprogs 6.9 stuff so that I can resend the new parent pointer code[1] for 6.10 which blows away the last of the old SGI pptr code.
--D
[1] https://lore.kernel.org/linux-xfs/170405006341.1804688.11009892277015794783.stgit@frogsfrogsfrogs/
Quoted 30 lines
--- io/parent.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)io/parent.c +2
-2@@ -112,7 +112,7 @@ check_parents(parent_t *parentbuf, size_t *parentbuf_size, jdm_fshandle_t *fshandlep, struct xfs_bstat *statp) { int error, i; -__u32 count; +__u32 count =0 ;parent_t *entryp; do {@@ -126,7 +126,7 @@ check_parents(parent_t *parentbuf, size_t *parentbuf_size, (unsigned long long ) statp->bs_ino, strerror(errno)); err_status++; -break ; +return ; } }while (error ==ERANGE );Signature · 1 line
2.45.1
Re: [PATCH 2/2] xfs_io: Fix do not loop through uninitialized var
Quoted 12 lines · Darrick J. Wong
Quoted 11 lines · Pavel Reichl
Red Hat's covscan checker found the following issue:
xfsprogs-6.4.0/io/parent.c:115:2:var_decl: Declaring variable "count" without initializer.xfsprogs-6.4.0/io/parent.c:134:2:uninit_use: Using uninitialized value "count".Currently,
jdm_parentpaths()returns EOPNOTSUPP and does not initialize the count variable. The count variable is subsequently used in a for loop, which leads to undefined behavior. Fix this by returning from thecheck_parents()function immediately after checking the return value of thejdm_parentpaths()function.
Quoted 5 lines
Quoted 1 line
Signed-off-by Pavel Reichl <[email protected]>I'm waiting on Carlos to take the xfsprogs 6.9 stuff so that I can resend the new parent pointer code[1] for 6.10 which blows away the last of the old SGI pptr code.
I'm working on it :) sorry the delay should be ready most late next week.
Quoted 36 lines
--D
[1] https://lore.kernel.org/linux-xfs/170405006341.1804688.11009892277015794783.stgit@frogsfrogsfrogs/
Quoted 30 lines
--- io/parent.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)io/parent.c +2
-3@@ -112,7 +112,7 @@ check_parents(parent_t *parentbuf, size_t *parentbuf_size, jdm_fshandle_t *fshandlep, struct xfs_bstat *statp) { int error, i; -__u32 count; +__u32 count =0 ;parent_t *entryp; do {@@ -126,7 +126,7 @@ check_parents(parent_t *parentbuf, size_t *parentbuf_size, (unsigned long long ) statp->bs_ino, strerror(errno)); err_status++; -break ; +return ; } }while (error ==ERANGE ); --2.45.1