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