libselinux: Close leaked FILEs
PATCH 1/1 libselinux: Close leaked FILEs
Fixes:
label_media.c:94:24: warning: leak of FILE ‘fopen (path_28, "re")’ [CWE-775] [-Wanalyzer-file-leak] label_x.c:121:24: warning: leak of FILE ‘fopen (path_28, "re")’ [CWE-775] [-Wanalyzer-file-leak]
Signed-off-by Petr Lautrbach <[email protected]>
--- libselinux/src/label_media.c | 4 ++-- libselinux/src/label_x.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-)
libselinux/src/label_media.c +2 -2
@@ -95,10 +95,10 @@ static int init(struct selabel_handle *rec, const struct selinux_opt *opts,__fsetlocking (fp,FSETLOCKING_BYCALLER );if (fstat (fileno (fp), &sb) <0 ) -return -1 ; + goto finish;if (!S_ISREG (sb.st_mode)) { errno =EINVAL ; -return -1 ; + goto finish; } rec->spec_file =strdup (path);
libselinux/src/label_x.c +2 -2
@@ -122,10 +122,10 @@ static int init(struct selabel_handle *rec, const struct selinux_opt *opts,__fsetlocking (fp,FSETLOCKING_BYCALLER );if (fstat (fileno (fp), &sb) <0 ) -return -1 ; + goto finish;if (!S_ISREG (sb.st_mode)) { errno =EINVAL ; -return -1 ; + goto finish; } rec->spec_file =strdup (path);
Signature · 1 line
2.35.1
Quoted 6 lines · Petr Lautrbach
Fixes:
label_media.c:94:24: warning: leak of FILE ‘fopen (path_28, "re")’ [CWE-775] [-Wanalyzer-file-leak] label_x.c:121:24: warning: leak of FILE ‘fopen (path_28, "re")’ [CWE-775] [-Wanalyzer-file-leak]Signed-off-by Petr Lautrbach <[email protected]>
Acked-by James Carter <[email protected]>
Quoted 42 lines
--- libselinux/src/label_media.c | 4 ++-- libselinux/src/label_x.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-)libselinux/src/label_media.c +2
-2@@ -95,10 +95,10 @@ static int init(struct selabel_handle *rec, const struct selinux_opt *opts,__fsetlocking (fp,FSETLOCKING_BYCALLER );if (fstat (fileno (fp), &sb) <0 ) -return -1 ; + goto finish;if (!S_ISREG (sb.st_mode)) { errno =EINVAL ; -return -1 ; + goto finish; } rec->spec_file =strdup (path);libselinux/src/label_x.c +2
-3@@ -122,10 +122,10 @@ static int init(struct selabel_handle *rec, const struct selinux_opt *opts,__fsetlocking (fp,FSETLOCKING_BYCALLER );if (fstat (fileno (fp), &sb) <0 ) -return -1 ; + goto finish;if (!S_ISREG (sb.st_mode)) { errno =EINVAL ; -return -1 ; + goto finish; } rec->spec_file =strdup (path); --2.35.1
Quoted 11 lines · James Carter
Quoted 6 lines · Petr Lautrbach
Fixes:
label_media.c:94:24: warning: leak of FILE ‘fopen (path_28, "re")’ [CWE-775] [-Wanalyzer-file-leak] label_x.c:121:24: warning: leak of FILE ‘fopen (path_28, "re")’ [CWE-775] [-Wanalyzer-file-leak]Signed-off-by Petr Lautrbach <[email protected]>Acked-by James Carter <[email protected]>
Merged.
Thanks,
Jim
Quoted 42 lines
Quoted 42 lines
--- libselinux/src/label_media.c | 4 ++-- libselinux/src/label_x.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-)libselinux/src/label_media.c +2
-2@@ -95,10 +95,10 @@ static int init(struct selabel_handle *rec, const struct selinux_opt *opts,__fsetlocking (fp,FSETLOCKING_BYCALLER );if (fstat (fileno (fp), &sb) <0 ) -return -1 ; + goto finish;if (!S_ISREG (sb.st_mode)) { errno =EINVAL ; -return -1 ; + goto finish; } rec->spec_file =strdup (path);libselinux/src/label_x.c +2
-3@@ -122,10 +122,10 @@ static int init(struct selabel_handle *rec, const struct selinux_opt *opts,__fsetlocking (fp,FSETLOCKING_BYCALLER );if (fstat (fileno (fp), &sb) <0 ) -return -1 ; + goto finish;if (!S_ISREG (sb.st_mode)) { errno =EINVAL ; -return -1 ; + goto finish; } rec->spec_file =strdup (path); --2.35.1