Skip to contentSkip to conversation

Replace non-thread-safe strtok function calls in gssd

PATCH In review Frank Sorenson 2 participants 2 messages Feb 9, 2017 – Feb 16, 2017

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH v2 1/2 Replace non-thread-safe strtok function calls in gssd

Author: Frank Sorenson <[email protected]>
Date:   2017-02-09 16:35:51 -0600

gssd: replace non-thread-safe strtok with strsep

gssd uses the non-thread-safe strtok() function, which can lead to incorrect program behavior.

Replace strtok() with the thread-safe strsep().

utils/gssd/gssd_proc.c +2 -1
index d74d372..30c6ace 100644
@@ -729,10 +729,11 @@ handle_gssd_upcall(struct clnt_upcall_info *info)
 	char			*target = NULL;
 	char			*service = NULL;
 	char			*enctypes = NULL;
+	char			*pbuf = info->lbuf;
 
 	printerr(2, "\n%s: '%s' (%s)\n", __func__, info->lbuf, clp->relpath);
 
-	for (p = strtok(info->lbuf, " "); p; p = strtok(NULL, " ")) {
+	while ((p = strsep(&pbuf, " "))) {
 		if (!strncmp(p, "mech=", strlen("mech=")))
 			mech = p + strlen("mech=");
 		else if (!strncmp(p, "uid=", strlen("uid=")))
#1 lore raw
Quoted 11 lines · Frank Sorenson
Author: Frank Sorenson <[email protected]>
Date:   2017-02-09 16:35:51 -0600

gssd: replace non-thread-safe strtok with strsep

gssd uses the non-thread-safe strtok() function, which can lead to incorrect program behavior.

Replace strtok() with the thread-safe strsep().

Committed....

steved.

Quoted 22 lines
utils/gssd/gssd_proc.c +2 -2
index d74d372..30c6ace 100644
@@ -729,10 +729,11 @@ handle_gssd_upcall(struct clnt_upcall_info *info)
 	char			*target = NULL;
 	char			*service = NULL;
 	char			*enctypes = NULL;
+	char			*pbuf = info->lbuf;
 
 	printerr(2, "\n%s: '%s' (%s)\n", __func__, info->lbuf, clp->relpath);
 
-	for (p = strtok(info->lbuf, " "); p; p = strtok(NULL, " ")) {
+	while ((p = strsep(&pbuf, " "))) {
 		if (!strncmp(p, "mech=", strlen("mech=")))
 			mech = p + strlen("mech=");
 		else if (!strncmp(p, "uid=", strlen("uid=")))
--

To unsubscribe from this list: send the line "unsubscribe linux-nfs" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html