libsepol/tests: read_binary_policy() does not use f.handle
PATCH 1/3 libsepol/tests: read_binary_policy() does not use f.handle
f.handle is never set in read_binary_policy() so there is no need to call sepol_handle_destroy() on it. Moreover clang's static analyzer warns about an uninitialized argument value in the first call.
Signed-off-by Nicolas Iooss <[email protected]>
--- libsepol/tests/test-downgrade.c | 2 -- 1 file changed, 2 deletions(-)
libsepol/tests/test-downgrade.c +0 -2
@@ -210,7 +210,6 @@ int read_binary_policy(const char *path, policydb_t *p)if ((in_fp =fopen (path,"rb" )) ==NULL ) {fprintf (stderr,"Unable to open %s: %s\n" , path,strerror (errno)); -sepol_handle_destroy (f.handle);return -1 ; }
@@ -220,7 +219,6 @@ int read_binary_policy(const char *path, policydb_t *p) f.fp = in_fp; rc =policydb_read (p, &f,0 ); -sepol_handle_destroy (f.handle);fclose (in_fp);return rc; }
Signature · 1 line
2.17.1
PATCH 2/3 libsepol/tests: fix use of unitialized variable
When write_binary_policy() fails to open the binary policy, it calls sepol_handle_destroy(f.handle) but structure f has not been initialized at this point. Use variable handle instead.
This issue has been found using clang's static analyzer.
Signed-off-by Nicolas Iooss <[email protected]>
--- libsepol/tests/test-downgrade.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
libsepol/tests/test-downgrade.c +1 -1
@@ -254,7 +254,7 @@ int write_binary_policy(const char *path, policydb_t *p)if ((out_fp =fopen (path,"w" )) ==NULL ) {fprintf (stderr,"Unable to open %s: %s\n" , path,strerror (errno)); -sepol_handle_destroy (f.handle); +sepol_handle_destroy (handle);return -1 ; }
Signature · 1 line
2.17.1
PATCH 3/3 libsepol/cil: use a colon instead of a semicolon to report rc
In reply to Nicolas IoossSigned-off-by Nicolas Iooss <[email protected]>
--- libsepol/cil/src/cil_resolve_ast.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
libsepol/cil/src/cil_resolve_ast.c +1 -1
@@ -2923,7 +2923,7 @@ int cil_resolve_call1(struct cil_tree_node *current, void *extra_args) rc =cil_fill_ipaddr (pc->cl_head, ipaddr);if (rc !=SEPOL_OK ) { -cil_log (CIL_ERR ,"Failed to create anonymous ip address, rc; %d\n" , rc); +cil_log (CIL_ERR ,"Failed to create anonymous ip address, rc: %d\n" , rc);cil_destroy_ipaddr (ipaddr); goto exit; }
Signature · 1 line
2.17.1
Stephen Smalley
AppliedRe: [PATCH 3/3] libsepol/cil: use a colon instead of a semicolon to report rc
Quoted 1 line · Nicolas Iooss
Signed-off-by Nicolas Iooss <[email protected]>
Thanks, applied all three.
Quoted 18 lines
--- libsepol/cil/src/cil_resolve_ast.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)libsepol/cil/src/cil_resolve_ast.c +1
-1@@ -2923,7 +2923,7 @@ int cil_resolve_call1(struct cil_tree_node *current, void *extra_args) rc =cil_fill_ipaddr (pc->cl_head, ipaddr);if (rc !=SEPOL_OK ) { -cil_log (CIL_ERR ,"Failed to create anonymous ip address, rc; %d\n" , rc); +cil_log (CIL_ERR ,"Failed to create anonymous ip address, rc: %d\n" , rc);cil_destroy_ipaddr (ipaddr); goto exit; }