about summary refs log tree commit diff
path: root/nscd/grpcache.c
diff options
context:
space:
mode:
Diffstat (limited to 'nscd/grpcache.c')
-rw-r--r--nscd/grpcache.c12
1 files changed, 11 insertions, 1 deletions
diff --git a/nscd/grpcache.c b/nscd/grpcache.c
index 93a7a0d86d..05ba40ed7c 100644
--- a/nscd/grpcache.c
+++ b/nscd/grpcache.c
@@ -246,8 +246,18 @@ addgrbygid (struct database *db, int fd, request_header *req,
   char *buffer = alloca (buflen);
   struct group resultbuf;
   struct group *grp;
-  gid_t gid = atol (key);
   uid_t oldeuid = 0;
+  char *ep;
+  gid_t gid = strtoul ((char *)key, &ep, 10); 
+  
+  if (*(char*)key == '\0' || *ep != '\0')  /* invalid numeric gid */
+    {
+      if (debug_level > 0)
+        dbg_log (_("Invalid numeric gid \"%s\"!"), (char *)key);
+
+      errno = EINVAL;
+      return;
+    }
 
   if (debug_level > 0)
     dbg_log (_("Haven't found \"%d\" in group cache!"), gid);