mcstrans: Fix check in raw_color()
PATCH 1/1 mcstrans: Fix check in raw_color()
raw_color() uses color_str as an output argument which is assigned to a new allocated memory. Therefore it should fail when color_str is null; or when *color_str is not null in order to avoid a memory leak.
Fixes:
Quoted 1 line
Quoted 1 line
Quoted 1 line
selinux.selinux_raw_context_to_color('system_u:system_r:inetd_t:s0')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
OSError: [Errno 0] Error
--- mcstrans/src/mcscolor.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
mcstrans/src/mcscolor.c +1 -1
@@ -292,7 +292,7 @@ int raw_color(const security_context_t raw, char **color_str) {size_t result_size = (N_COLOR *CHARS_PER_COLOR ) +1 ;int rc =-1 ; -if (!color_str || !*color_str) { +if (!color_str || *color_str) {return -1 ; }
Signature · 1 line
2.20.0
Quoted 5 lines · Petr Lautrbach
raw_color()usescolor_stras an output argument which is assigned to a new allocated memory. Therefore it should fail whencolor_stris null; or when*color_stris not null in order to avoid a memory leak.
Quoted 7 lines
Fixes:
Quoted 1 line
Quoted 1 line
Quoted 1 line
selinux.selinux_raw_context_to_color('system_u:system_r:inetd_t:s0')Traceback (most recent call last):
File "<stdin>", line 1, in <module>
OSError: [Errno 0] ErrorSigned-off-by Petr Lautrbach <[email protected]>
Quoted 20 lines
--- mcstrans/src/mcscolor.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)mcstrans/src/mcscolor.c +1
-2@@ -292,7 +292,7 @@ int raw_color(const security_context_t raw, char **color_str) {size_t result_size = (N_COLOR *CHARS_PER_COLOR ) +1 ;int rc =-1 ; -if (!color_str || !*color_str) { +if (!color_str || *color_str) {return -1 ; } --2.20.0