Skip to contentSkip to conversation

libselinux/utils: use correct error handling

PATCH In review Christian Göttsche 2 participants 3 messages Nov 28, 2024 – Dec 4, 2024 SELinux security module

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 libselinux/utils: use correct error handling

From: Christian Göttsche <[email protected]>

Instead of returning directly goto the err label, which prints a message and closes the opened file stream.

Found by clang-analyzer.

---
 libselinux/utils/sefcontext_compile.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
libselinux/utils/sefcontext_compile.c +1 -1
index 23d31274..5d7ab301 100644
@@ -471,7 +471,7 @@ static int write_binary_file(const struct saved_data *data, const struct sidtab
 	/* write context table */
 	rc = write_sidtab(bin_file, stab);
 	if (rc)
-		return rc;
+		goto err;
 
 	rc = write_spec_node(bin_file, do_write_precompregex, data->root, stab);
 	if (rc)
Signature · 1 line
2.45.2
Acked-by on v1 1/1
#1 lore raw
Quoted 9 lines · Christian Göttsche

From: Christian Göttsche <[email protected]>

Instead of returning directly goto the err label, which prints a message and closes the opened file stream.

Found by clang-analyzer.

Quoted 21 lines
---
 libselinux/utils/sefcontext_compile.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
libselinux/utils/sefcontext_compile.c +1 -2
index 23d31274..5d7ab301 100644
@@ -471,7 +471,7 @@ static int write_binary_file(const struct saved_data *data, const struct sidtab
        /* write context table */
        rc = write_sidtab(bin_file, stab);
        if (rc)
-               return rc;
+               goto err;
 
        rc = write_spec_node(bin_file, do_write_precompregex, data->root, stab);
        if (rc)
--

2.45.2

#2 lore raw
Quoted 6 lines · James Carter
Quoted 3 lines · Christian Göttsche

From: Christian Göttsche <[email protected]>

Quoted 9 lines
Quoted 6 lines

Instead of returning directly goto the err label, which prints a message and closes the opened file stream.

Found by clang-analyzer.

Merged.
Thanks,
Jim

Quoted 21 lines
Quoted 21 lines
---
 libselinux/utils/sefcontext_compile.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
libselinux/utils/sefcontext_compile.c +1 -2
index 23d31274..5d7ab301 100644
@@ -471,7 +471,7 @@ static int write_binary_file(const struct saved_data *data, const struct sidtab
        /* write context table */
        rc = write_sidtab(bin_file, stab);
        if (rc)
-               return rc;
+               goto err;
 
        rc = write_spec_node(bin_file, do_write_precompregex, data->root, stab);
        if (rc)
--

2.45.2