policycoreutils: strdup() check, use null character
cover policycoreutils: strdup() check, use null character
policycoreutils: Use null character in strings. Check strdup() failure.
Kalevi Kolttonen (2):
policycoreutils: use null character in strings
policycoreutils: check strdup() failure
policycoreutils/secon/secon.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)
Signature · 1 line
2.54.0
PATCH 1/2 policycoreutils: use null character in strings
Signed-off-by Kalevi Kolttonen <[email protected]>
--- policycoreutils/secon/secon.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
policycoreutils/secon/secon.c +2 -2
@@ -373,7 +373,7 @@ static int my_getXcon_raw(pid_t pid, char **con, const char *val)char *tmp =strchr (ptr,'\n' );if (tmp) - *tmp =0 ; + *tmp ='\0' ;if (*ptr && !(*con =strdup (ptr)))return (-1 );
@@ -422,7 +422,7 @@ static char *get_scon(void) " Couldn't read security context"); ptr +=strspn (ptr," \n\t" ); - ptr[strcspn (ptr," \n\t" )] =0 ; + ptr[strcspn (ptr," \n\t" )] ='\0' ; }if (!(con_tmp =strdup (ptr)))
Signature · 1 line
2.54.0
Re: [PATCH 1/2] policycoreutils: use null character in strings
Quoted 2 lines · Kalevi Kolttonen
Signed-off-by Kalevi Kolttonen <[email protected]>
Acked-by Stephen Smalley <[email protected]>
Quoted 30 lines
--- policycoreutils/secon/secon.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)policycoreutils/secon/secon.c +2
-3@@ -373,7 +373,7 @@ static int my_getXcon_raw(pid_t pid, char **con, const char *val)char *tmp =strchr (ptr,'\n' );if (tmp) - *tmp =0 ; + *tmp ='\0' ;if (*ptr && !(*con =strdup (ptr)))return (-1 );@@ -422,7 +422,7 @@ static char *get_scon(void) " Couldn't read security context"); ptr +=strspn (ptr," \n\t" ); - ptr[strcspn (ptr," \n\t" )] =0 ; + ptr[strcspn (ptr," \n\t" )] ='\0' ; }if (!(con_tmp =strdup (ptr))) --2.54.0
PATCH 2/2 policycoreutils: check strdup() failure
In reply to Kalevi KolttonenSigned-off-by Kalevi Kolttonen <[email protected]>
--- policycoreutils/secon/secon.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
policycoreutils/secon/secon.c +4 -1
@@ -516,8 +516,11 @@ static char *get_scon(void)" Couldn't get security context for pid %lu" , (unsigned long)opts->f.pid); -if (!con) +if (!con) { con =strdup (dummy_NIL); +if (!con) +err (EXIT_FAILURE ,"Out of memory" ); + }break ;case OPTS_FROM_FILE :
Signature · 1 line
2.54.0
Re: [PATCH 2/2] policycoreutils: check strdup() failure
Quoted 2 lines · Kalevi Kolttonen
Signed-off-by Kalevi Kolttonen <[email protected]>
Acked-by Stephen Smalley <[email protected]>
Quoted 25 lines
--- policycoreutils/secon/secon.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)policycoreutils/secon/secon.c +4
-2@@ -516,8 +516,11 @@ static char *get_scon(void)" Couldn't get security context for pid %lu" , (unsigned long)opts->f.pid); -if (!con) +if (!con) { con =strdup (dummy_NIL); +if (!con) +err (EXIT_FAILURE ,"Out of memory" ); + }break ;case OPTS_FROM_FILE : --2.54.0