restorecond: add check for strdup in strings_list_add
PATCH 1/1 restorecond: add check for strdup in strings_list_add
Check the return value of strdup() to avoid null pointer reference.
Signed-off-by Huaxin Lu <[email protected]>
--- restorecond/stringslist.c | 2 ++ 1 file changed, 2 insertions(+)
restorecond/stringslist.c +2 -0
@@ -48,6 +48,8 @@ void strings_list_add(struct stringsList **list, const char *string)if (!newptr)exitApp ("Out of Memory" ); newptr->string =strdup (string); +if (!newptr->string) +exitApp ("Out of Memory" ); newptr->next = ptr;if (prev) prev->next = newptr;
Signature · 1 line
2.33.0
Quoted 4 lines · Huaxin Lu
Check the return value of
strdup()to avoid null pointer reference.Signed-off-by Huaxin Lu <[email protected]>
Acked-by James Carter <[email protected]>
Quoted 20 lines
--- restorecond/stringslist.c | 2 ++ 1 file changed, 2 insertions(+)restorecond/stringslist.c +2
-1@@ -48,6 +48,8 @@ void strings_list_add(struct stringsList **list, const char *string)if (!newptr)exitApp ("Out of Memory" ); newptr->string =strdup (string); +if (!newptr->string) +exitApp ("Out of Memory" ); newptr->next = ptr;if (prev) prev->next = newptr; --2.33.0
Quoted 9 lines · James Carter
Quoted 4 lines · Huaxin Lu
Check the return value of
strdup()to avoid null pointer reference.Signed-off-by Huaxin Lu <[email protected]>Acked-by James Carter <[email protected]>
Merged.
Thanks,
Jim
Quoted 21 lines
Quoted 21 lines
--- restorecond/stringslist.c | 2 ++ 1 file changed, 2 insertions(+)restorecond/stringslist.c +2
-1@@ -48,6 +48,8 @@ void strings_list_add(struct stringsList **list, const char *string)if (!newptr)exitApp ("Out of Memory" ); newptr->string =strdup (string); +if (!newptr->string) +exitApp ("Out of Memory" ); newptr->next = ptr;if (prev) prev->next = newptr; --2.33.0