[nfs-utils,V2,1/2] Replace non-thread-safe strtok function calls in gssd
diff mbox

Message ID 911ff1ff-ac59-2c10-e165-cd1186b1f940@redhat.com
State New
Headers show

Commit Message

Frank Sorenson Feb. 9, 2017, 11:01 p.m. UTC
Author: Frank Sorenson <sorenson@redhat.com>
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().
    
    Signed-off-by: Frank Sorenson <sorenson@redhat.com>

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

Comments

Steve Dickson Feb. 16, 2017, 10:23 a.m. UTC | #1
On 02/09/2017 06:01 PM, Frank Sorenson wrote:
> Author: Frank Sorenson <sorenson@redhat.com>
> 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().
>     
>     Signed-off-by: Frank Sorenson <sorenson@redhat.com>
Committed....

steved.
>
> diff --git a/utils/gssd/gssd_proc.c b/utils/gssd/gssd_proc.c
> index d74d372..30c6ace 100644
> --- a/utils/gssd/gssd_proc.c
> +++ b/utils/gssd/gssd_proc.c
> @@ -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 majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

Patch
diff mbox

diff --git a/utils/gssd/gssd_proc.c b/utils/gssd/gssd_proc.c
index d74d372..30c6ace 100644
--- a/utils/gssd/gssd_proc.c
+++ b/utils/gssd/gssd_proc.c
@@ -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=")))