diff mbox series

[20/47] libsemanage: use strtok_r for thread safety

Message ID 20241111141706.38039-20-cgoettsche@seltendoof.de (mailing list archive)
State New
Delegated to: Petr Lautrbach
Headers show
Series [01/47] libsemanage: white space cleanup | expand

Commit Message

Christian Göttsche Nov. 11, 2024, 2:16 p.m. UTC
From: Christian Göttsche <cgzones@googlemail.com>

Use strtok_r(3) for thread safety, not only against concurrent usage
within libsemanage but also other linked libraries in the application.

Signed-off-by: Christian Göttsche <cgzones@googlemail.com>
---
 libsemanage/src/genhomedircon.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
diff mbox series

Patch

diff --git a/libsemanage/src/genhomedircon.c b/libsemanage/src/genhomedircon.c
index 29ff4259..5e7315d8 100644
--- a/libsemanage/src/genhomedircon.c
+++ b/libsemanage/src/genhomedircon.c
@@ -144,10 +144,10 @@  static void ignore_free(void) {
 }
 
 static int ignore_setup(char *ignoredirs) {
-	char *tok;
+	char *tok, *saveptr = NULL;
 	ignoredir_t *ptr = NULL;
 
-	tok = strtok(ignoredirs, ";");
+	tok = strtok_r(ignoredirs, ";", &saveptr);
 	while(tok) {
 		ptr = calloc(1, sizeof(ignoredir_t));
 		if (!ptr)
@@ -159,7 +159,7 @@  static int ignore_setup(char *ignoredirs) {
 		ptr->next = ignore_head;
 		ignore_head = ptr;
 
-		tok = strtok(NULL, ";");
+		tok = strtok_r(NULL, ";", &saveptr);
 	}
 
 	return 0;