linux-nfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] nss_getpwnam: correctly check for negative values in unsigned ints.
@ 2016-08-17 17:50 Steve Dickson
  0 siblings, 0 replies; only message in thread
From: Steve Dickson @ 2016-08-17 17:50 UTC (permalink / raw)
  To: Linux NFS Mailing list

commit e22368f6 introduce a couple checks for
negative buffer lengths. The variables are unsigned
ints so UINT_MAX should be used.

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

diff --git a/nss.c b/nss.c
index 8e9412d..47c6b14 100644
--- a/nss.c
+++ b/nss.c
@@ -44,6 +44,7 @@
 #include <netdb.h>
 #include <err.h>
 #include <grp.h>
+#include <limits.h>
 #include "nfsidmap.h"
 #include "nfsidmap_internal.h"
 #include "cfg.h"
@@ -171,7 +172,7 @@ static struct passwd *nss_getpwnam(const char *name, const char *domain, int *er
 	char *localname;
 	int err = ENOMEM;
 
-	if (buflen < 0)
+	if (buflen > UINT_MAX)
 		goto err;
 
 	buf = malloc(sizeof(*buf) + buflen);
@@ -240,7 +241,7 @@ static int nss_name_to_gid(char *name, gid_t *gid)
 		goto out;
 
 	err = -ENOMEM;
-	if (buflen < 0)
+	if (buflen > UINT_MAX)
 		goto out;
 
 	do {
-- 
2.7.4


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2016-08-17 17:57 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-08-17 17:50 [PATCH] nss_getpwnam: correctly check for negative values in unsigned ints Steve Dickson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).