diff mbox

nfsidmap: make sure given arguments are valid

Message ID 1430417344-25020-2-git-send-email-steved@redhat.com (mailing list archive)
State New, archived
Headers show

Commit Message

Steve Dickson April 30, 2015, 6:09 p.m. UTC
Detect when a given argument is invalid. Log
the error and exit gracefully

Signed-off-by: Steve Dickson <steved@redhat.com>
---
 utils/nfsidmap/nfsidmap.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

Comments

Steve Dickson May 4, 2015, 11:37 a.m. UTC | #1
On 04/30/2015 02:09 PM, Steve Dickson wrote:
> Detect when a given argument is invalid. Log
> the error and exit gracefully
> 
> Signed-off-by: Steve Dickson <steved@redhat.com>
Committed...

steved.

> ---
>  utils/nfsidmap/nfsidmap.c | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/utils/nfsidmap/nfsidmap.c b/utils/nfsidmap/nfsidmap.c
> index 5d62078..1f5ba67 100644
> --- a/utils/nfsidmap/nfsidmap.c
> +++ b/utils/nfsidmap/nfsidmap.c
> @@ -323,7 +323,10 @@ int main(int argc, char **argv)
>  	}
>  	type = strtok(arg, ":");
>  	value = strtok(NULL, ":");
> -
> +    if (value == NULL) {
> +		xlog_err("Error: Null uid/gid value.");
> +		return 1;
> +	}
>  	if (verbose) {
>  		xlog_warn("key: 0x%lx type: %s value: %s timeout %ld",
>  			key, type, value, timeout);
> 
--
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
diff mbox

Patch

diff --git a/utils/nfsidmap/nfsidmap.c b/utils/nfsidmap/nfsidmap.c
index 5d62078..1f5ba67 100644
--- a/utils/nfsidmap/nfsidmap.c
+++ b/utils/nfsidmap/nfsidmap.c
@@ -323,7 +323,10 @@  int main(int argc, char **argv)
 	}
 	type = strtok(arg, ":");
 	value = strtok(NULL, ":");
-
+    if (value == NULL) {
+		xlog_err("Error: Null uid/gid value.");
+		return 1;
+	}
 	if (verbose) {
 		xlog_warn("key: 0x%lx type: %s value: %s timeout %ld",
 			key, type, value, timeout);