All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] Handle NULL names better
@ 2015-04-30 18:09 Steve Dickson
  2015-04-30 18:09 ` [PATCH] nfsidmap: make sure given arguments are valid Steve Dickson
  2015-05-04 11:35 ` [PATCH] Handle NULL names better Steve Dickson
  0 siblings, 2 replies; 4+ messages in thread
From: Steve Dickson @ 2015-04-30 18:09 UTC (permalink / raw)
  To: Linux NFS Mailing list

Detect when an application passes in NULL names
and fail gracefully instead of crashing hard.

Signed-off-by: Steve Dickson <steved@redhat.com>
---
 libnfsidmap.c | 5 ++++-
 nss.c         | 3 +++
 2 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/libnfsidmap.c b/libnfsidmap.c
index 833f94c..a8a9229 100644
--- a/libnfsidmap.c
+++ b/libnfsidmap.c
@@ -100,8 +100,11 @@ static char * toupper_str(char *s)
 
 static int id_as_chars(char *name, uid_t *id)
 {
-	long int value = strtol(name, NULL, 10);
+	long int value;
 
+	if (name == NULL)
+		return 0;
+	value = strtol(name, NULL, 10);
 	if (value == 0) {
 		/* zero value ids are valid */
 		if (strcmp(name, "0") != 0)
diff --git a/nss.c b/nss.c
index f8129fe..b3fef5a 100644
--- a/nss.c
+++ b/nss.c
@@ -135,6 +135,9 @@ static char *strip_domain(const char *name, const char *domain)
 	char *l = NULL;
 	int len;
 
+	if (name == NULL)
+		goto out;
+
 	c = strrchr(name, '@');
 	if (c == NULL && domain != NULL)
 		goto out;
-- 
2.1.0


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

* [PATCH] nfsidmap: make sure given arguments are valid
  2015-04-30 18:09 [PATCH] Handle NULL names better Steve Dickson
@ 2015-04-30 18:09 ` Steve Dickson
  2015-05-04 11:37   ` Steve Dickson
  2015-05-04 11:35 ` [PATCH] Handle NULL names better Steve Dickson
  1 sibling, 1 reply; 4+ messages in thread
From: Steve Dickson @ 2015-04-30 18:09 UTC (permalink / raw)
  To: Linux NFS Mailing list

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(-)

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);
-- 
2.1.0


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

* Re: [PATCH] Handle NULL names better
  2015-04-30 18:09 [PATCH] Handle NULL names better Steve Dickson
  2015-04-30 18:09 ` [PATCH] nfsidmap: make sure given arguments are valid Steve Dickson
@ 2015-05-04 11:35 ` Steve Dickson
  1 sibling, 0 replies; 4+ messages in thread
From: Steve Dickson @ 2015-05-04 11:35 UTC (permalink / raw)
  To: Linux NFS Mailing list



On 04/30/2015 02:09 PM, Steve Dickson wrote:
> Detect when an application passes in NULL names
> and fail gracefully instead of crashing hard.
> 
> Signed-off-by: Steve Dickson <steved@redhat.com>
Committed...

steved.
> ---
>  libnfsidmap.c | 5 ++++-
>  nss.c         | 3 +++
>  2 files changed, 7 insertions(+), 1 deletion(-)
> 
> diff --git a/libnfsidmap.c b/libnfsidmap.c
> index 833f94c..a8a9229 100644
> --- a/libnfsidmap.c
> +++ b/libnfsidmap.c
> @@ -100,8 +100,11 @@ static char * toupper_str(char *s)
>  
>  static int id_as_chars(char *name, uid_t *id)
>  {
> -	long int value = strtol(name, NULL, 10);
> +	long int value;
>  
> +	if (name == NULL)
> +		return 0;
> +	value = strtol(name, NULL, 10);
>  	if (value == 0) {
>  		/* zero value ids are valid */
>  		if (strcmp(name, "0") != 0)
> diff --git a/nss.c b/nss.c
> index f8129fe..b3fef5a 100644
> --- a/nss.c
> +++ b/nss.c
> @@ -135,6 +135,9 @@ static char *strip_domain(const char *name, const char *domain)
>  	char *l = NULL;
>  	int len;
>  
> +	if (name == NULL)
> +		goto out;
> +
>  	c = strrchr(name, '@');
>  	if (c == NULL && domain != NULL)
>  		goto out;
> 

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

* Re: [PATCH] nfsidmap: make sure given arguments are valid
  2015-04-30 18:09 ` [PATCH] nfsidmap: make sure given arguments are valid Steve Dickson
@ 2015-05-04 11:37   ` Steve Dickson
  0 siblings, 0 replies; 4+ messages in thread
From: Steve Dickson @ 2015-05-04 11:37 UTC (permalink / raw)
  To: Linux NFS Mailing list



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);
> 

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

end of thread, other threads:[~2015-05-04 11:37 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-04-30 18:09 [PATCH] Handle NULL names better Steve Dickson
2015-04-30 18:09 ` [PATCH] nfsidmap: make sure given arguments are valid Steve Dickson
2015-05-04 11:37   ` Steve Dickson
2015-05-04 11:35 ` [PATCH] Handle NULL names better 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.