All of lore.kernel.org
 help / color / mirror / Atom feed
* [nfs-utils PATCH V2 2/2] Duplicate upcall string for use in error messages
@ 2017-02-09 23:04 Frank Sorenson
  2017-02-16 10:24 ` Steve Dickson
  0 siblings, 1 reply; 2+ messages in thread
From: Frank Sorenson @ 2017-02-09 23:04 UTC (permalink / raw)
  To: linux-nfs

Author: Frank Sorenson <sorenson@redhat.com>
Date:   2017-02-09 16:51:44 -0600

    gssd:  Duplicate the upcall string for error messages
    
    strsep() modifies the input string, so error messages
    may output only part of the upcall string.
    
    Make a copy of the upcall string, and use that in any
    error messages.
    
    Signed-off-by: Frank Sorenson <sorenson@redhat.com>

diff --git a/utils/gssd/gssd_proc.c b/utils/gssd/gssd_proc.c
index 30c6ace..4fc81c3 100644
--- a/utils/gssd/gssd_proc.c
+++ b/utils/gssd/gssd_proc.c
@@ -729,10 +729,17 @@ handle_gssd_upcall(struct clnt_upcall_info *info)
 	char			*target = NULL;
 	char			*service = NULL;
 	char			*enctypes = NULL;
+	char			*upcall_str;
 	char			*pbuf = info->lbuf;
 
 	printerr(2, "\n%s: '%s' (%s)\n", __func__, info->lbuf, clp->relpath);
 
+	upcall_str = strdup(info->lbuf);
+	if (upcall_str == NULL) {
+		printerr(0, "ERROR: malloc failure\n");
+		goto out_nomem;
+	}
+
 	while ((p = strsep(&pbuf, " "))) {
 		if (!strncmp(p, "mech=", strlen("mech=")))
 			mech = p + strlen("mech=");
@@ -749,7 +756,7 @@ handle_gssd_upcall(struct clnt_upcall_info *info)
 	if (!mech || strlen(mech) < 1) {
 		printerr(0, "WARNING: handle_gssd_upcall: "
 			    "failed to find gss mechanism name "
-			    "in upcall string '%s'\n", info->lbuf);
+			    "in upcall string '%s'\n", upcall_str);
 		goto out;
 	}
 
@@ -762,7 +769,7 @@ handle_gssd_upcall(struct clnt_upcall_info *info)
 	if (!uidstr) {
 		printerr(0, "WARNING: handle_gssd_upcall: "
 			    "failed to find uid "
-			    "in upcall string '%s'\n", info->lbuf);
+			    "in upcall string '%s'\n", upcall_str);
 		goto out;
 	}
 
@@ -775,7 +782,7 @@ handle_gssd_upcall(struct clnt_upcall_info *info)
 	if (target && strlen(target) < 1) {
 		printerr(0, "WARNING: handle_gssd_upcall: "
 			 "failed to parse target name "
-			 "in upcall string '%s'\n", info->lbuf);
+			 "in upcall string '%s'\n", upcall_str);
 		goto out;
 	}
 
@@ -790,7 +797,7 @@ handle_gssd_upcall(struct clnt_upcall_info *info)
 	if (service && strlen(service) < 1) {
 		printerr(0, "WARNING: handle_gssd_upcall: "
 			 "failed to parse service type "
-			 "in upcall string '%s'\n", info->lbuf);
+			 "in upcall string '%s'\n", upcall_str);
 		goto out;
 	}
 
@@ -803,6 +810,8 @@ handle_gssd_upcall(struct clnt_upcall_info *info)
 		do_error_downcall(clp->gssd_fd, uid, -EACCES);
 	}
 out:
+	free(upcall_str);
+out_nomem:
 	free(info);
 	return;
 }

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [nfs-utils PATCH V2 2/2] Duplicate upcall string for use in error messages
  2017-02-09 23:04 [nfs-utils PATCH V2 2/2] Duplicate upcall string for use in error messages Frank Sorenson
@ 2017-02-16 10:24 ` Steve Dickson
  0 siblings, 0 replies; 2+ messages in thread
From: Steve Dickson @ 2017-02-16 10:24 UTC (permalink / raw)
  To: Frank Sorenson, linux-nfs



On 02/09/2017 06:04 PM, Frank Sorenson wrote:
> Author: Frank Sorenson <sorenson@redhat.com>
> Date:   2017-02-09 16:51:44 -0600
>
>     gssd:  Duplicate the upcall string for error messages
>     
>     strsep() modifies the input string, so error messages
>     may output only part of the upcall string.
>     
>     Make a copy of the upcall string, and use that in any
>     error messages.
>     
>     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 30c6ace..4fc81c3 100644
> --- a/utils/gssd/gssd_proc.c
> +++ b/utils/gssd/gssd_proc.c
> @@ -729,10 +729,17 @@ handle_gssd_upcall(struct clnt_upcall_info *info)
>  	char			*target = NULL;
>  	char			*service = NULL;
>  	char			*enctypes = NULL;
> +	char			*upcall_str;
>  	char			*pbuf = info->lbuf;
>  
>  	printerr(2, "\n%s: '%s' (%s)\n", __func__, info->lbuf, clp->relpath);
>  
> +	upcall_str = strdup(info->lbuf);
> +	if (upcall_str == NULL) {
> +		printerr(0, "ERROR: malloc failure\n");
> +		goto out_nomem;
> +	}
> +
>  	while ((p = strsep(&pbuf, " "))) {
>  		if (!strncmp(p, "mech=", strlen("mech=")))
>  			mech = p + strlen("mech=");
> @@ -749,7 +756,7 @@ handle_gssd_upcall(struct clnt_upcall_info *info)
>  	if (!mech || strlen(mech) < 1) {
>  		printerr(0, "WARNING: handle_gssd_upcall: "
>  			    "failed to find gss mechanism name "
> -			    "in upcall string '%s'\n", info->lbuf);
> +			    "in upcall string '%s'\n", upcall_str);
>  		goto out;
>  	}
>  
> @@ -762,7 +769,7 @@ handle_gssd_upcall(struct clnt_upcall_info *info)
>  	if (!uidstr) {
>  		printerr(0, "WARNING: handle_gssd_upcall: "
>  			    "failed to find uid "
> -			    "in upcall string '%s'\n", info->lbuf);
> +			    "in upcall string '%s'\n", upcall_str);
>  		goto out;
>  	}
>  
> @@ -775,7 +782,7 @@ handle_gssd_upcall(struct clnt_upcall_info *info)
>  	if (target && strlen(target) < 1) {
>  		printerr(0, "WARNING: handle_gssd_upcall: "
>  			 "failed to parse target name "
> -			 "in upcall string '%s'\n", info->lbuf);
> +			 "in upcall string '%s'\n", upcall_str);
>  		goto out;
>  	}
>  
> @@ -790,7 +797,7 @@ handle_gssd_upcall(struct clnt_upcall_info *info)
>  	if (service && strlen(service) < 1) {
>  		printerr(0, "WARNING: handle_gssd_upcall: "
>  			 "failed to parse service type "
> -			 "in upcall string '%s'\n", info->lbuf);
> +			 "in upcall string '%s'\n", upcall_str);
>  		goto out;
>  	}
>  
> @@ -803,6 +810,8 @@ handle_gssd_upcall(struct clnt_upcall_info *info)
>  		do_error_downcall(clp->gssd_fd, uid, -EACCES);
>  	}
>  out:
> +	free(upcall_str);
> +out_nomem:
>  	free(info);
>  	return;
>  }
> --
> 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


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2017-02-16 10:24 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-02-09 23:04 [nfs-utils PATCH V2 2/2] Duplicate upcall string for use in error messages Frank Sorenson
2017-02-16 10:24 ` Steve Dickson

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.