checkpolicy/0012-checkpolicy-avoid-potential-use-of-uninitialized-var.patch
Petr Lautrbach a85176781b checkpolicy-3.2-3
Rebase on upstream commit 32611aea6543

See
    $ cd SELinuxProject/selinux
    $ git log --pretty=oneline checkpolicy-3.2..32611aea6543 -- checkpolicy

Resolves: rhbz#1988267
2021-07-30 14:42:21 +02:00

63 lines
2.2 KiB
Diff
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

From 5218bf4b262ae6c3aa0ec72c5116a73bbdb7806f Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Christian=20G=C3=B6ttsche?= <cgzones@googlemail.com>
Date: Tue, 6 Jul 2021 19:54:29 +0200
Subject: [PATCH] checkpolicy: avoid potential use of uninitialized variable
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
checkpolicy.c: In function main:
checkpolicy.c:1000:25: error: tsid may be used uninitialized in this function [-Werror=maybe-uninitialized]
1000 | printf("if_sid %d default_msg_sid %d\n", ssid, tsid);
| ^
checkpolicy.c: In function main:
checkpolicy.c:971:25: error: tsid may be used uninitialized in this function [-Werror=maybe-uninitialized]
971 | printf("fs_sid %d default_file_sid %d\n", ssid, tsid);
| ^
Found by GCC 11 with LTO enabled.
Signed-off-by: Christian Göttsche <cgzones@googlemail.com>
---
checkpolicy/checkpolicy.c | 16 ++++++++++++----
1 file changed, 12 insertions(+), 4 deletions(-)
diff --git a/checkpolicy/checkpolicy.c b/checkpolicy/checkpolicy.c
index 58edcc34e8cc..e6cfd3372022 100644
--- a/checkpolicy/checkpolicy.c
+++ b/checkpolicy/checkpolicy.c
@@ -970,8 +970,12 @@ int main(int argc, char **argv)
printf("fs kdevname? ");
FGETS(ans, sizeof(ans), stdin);
ans[strlen(ans) - 1] = 0;
- sepol_fs_sid(ans, &ssid, &tsid);
- printf("fs_sid %d default_file_sid %d\n", ssid, tsid);
+ ret = sepol_fs_sid(ans, &ssid, &tsid);
+ if (ret) {
+ printf("unknown fs kdevname\n");
+ } else {
+ printf("fs_sid %d default_file_sid %d\n", ssid, tsid);
+ }
break;
case '9':
printf("protocol? ");
@@ -999,8 +1003,12 @@ int main(int argc, char **argv)
printf("netif name? ");
FGETS(ans, sizeof(ans), stdin);
ans[strlen(ans) - 1] = 0;
- sepol_netif_sid(ans, &ssid, &tsid);
- printf("if_sid %d default_msg_sid %d\n", ssid, tsid);
+ ret = sepol_netif_sid(ans, &ssid, &tsid);
+ if (ret) {
+ printf("unknown name\n");
+ } else {
+ printf("if_sid %d default_msg_sid %d\n", ssid, tsid);
+ }
break;
case 'b':{
char *p;
--
2.32.0