From 8730e0762e36ae214932e2a2a84aedd573462357 Mon Sep 17 00:00:00 2001
From: Huaxin Lu <luhuaxin1@huawei.com>
Date: Tue, 11 Jul 2023 06:49:33 +0800
Subject: [PATCH] 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 <luhuaxin1@huawei.com>
Acked-by: James Carter <jwcart2@gmail.com>

Reference:https://github.com/SELinuxProject/selinux/commit/8730e0762e36ae214932e2a2a84aedd573462357
Conflict:NA
---
 restorecond/stringslist.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/restorecond/stringslist.c b/restorecond/stringslist.c
index f9404b1e..a76542a7 100644
--- a/restorecond/stringslist.c
+++ b/restorecond/stringslist.c
@@ -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.23.0
