55 lines
1.7 KiB
Diff
55 lines
1.7 KiB
Diff
|
|
From db69a3d3622005d3ffd62498eac8da1ded264874 Mon Sep 17 00:00:00 2001
|
||
|
|
From: =?UTF-8?q?Christian=20G=C3=B6ttsche?= <cgzones@googlemail.com>
|
||
|
|
Date: Mon, 3 May 2021 17:11:07 +0200
|
||
|
|
Reference:https://github.com/SELinuxProject/selinux/commit/db69a3d3622005d3ffd62498eac8da1ded264874
|
||
|
|
Conflict:adapter filepath
|
||
|
|
Subject: [PATCH] libselinux: getdefaultcon: free memory on multiple same
|
||
|
|
arguments
|
||
|
|
MIME-Version: 1.0
|
||
|
|
Content-Type: text/plain; charset=UTF-8
|
||
|
|
Content-Transfer-Encoding: 8bit
|
||
|
|
|
||
|
|
Do not leak memory if program arguments get specified more than once.
|
||
|
|
|
||
|
|
Found by clang-anlyzer.
|
||
|
|
|
||
|
|
getdefaultcon.c:52:3: warning: Potential leak of memory pointed to by 'level' [unix.Malloc]
|
||
|
|
fprintf(stderr,
|
||
|
|
^~~~~~~~~~~~~~~
|
||
|
|
getdefaultcon.c:52:3: warning: Potential leak of memory pointed to by 'role' [unix.Malloc]
|
||
|
|
fprintf(stderr,
|
||
|
|
^~~~~~~~~~~~~~~
|
||
|
|
getdefaultcon.c:52:3: warning: Potential leak of memory pointed to by 'service' [unix.Malloc]
|
||
|
|
fprintf(stderr,
|
||
|
|
^~~~~~~~~~~~~~~
|
||
|
|
|
||
|
|
Signed-off-by: Christian Göttsche <cgzones@googlemail.com>
|
||
|
|
Signed-off-by: luhuaxin <1539327763@qq.com>
|
||
|
|
---
|
||
|
|
libselinux/utils/getdefaultcon.c | 3 +++
|
||
|
|
1 file changed, 3 insertions(+)
|
||
|
|
|
||
|
|
diff --git a/utils/getdefaultcon.c b/utils/getdefaultcon.c
|
||
|
|
index 96a5a8c..957c1cb 100644
|
||
|
|
--- a/utils/getdefaultcon.c
|
||
|
|
+++ b/utils/getdefaultcon.c
|
||
|
|
@@ -28,12 +28,15 @@ int main(int argc, char **argv)
|
||
|
|
while ((opt = getopt(argc, argv, "l:r:s:v")) > 0) {
|
||
|
|
switch (opt) {
|
||
|
|
case 'l':
|
||
|
|
+ free(level);
|
||
|
|
level = strdup(optarg);
|
||
|
|
break;
|
||
|
|
case 'r':
|
||
|
|
+ free(role);
|
||
|
|
role = strdup(optarg);
|
||
|
|
break;
|
||
|
|
case 's':
|
||
|
|
+ free(service);
|
||
|
|
service = strdup(optarg);
|
||
|
|
break;
|
||
|
|
case 'v':
|
||
|
|
--
|
||
|
|
1.8.3.1
|
||
|
|
|