aboutsummaryrefslogtreecommitdiff
path: root/nscd/pwdcache.c
diff options
context:
space:
mode:
Diffstat (limited to 'nscd/pwdcache.c')
-rw-r--r--nscd/pwdcache.c12
1 files changed, 11 insertions, 1 deletions
diff --git a/nscd/pwdcache.c b/nscd/pwdcache.c
index 94d8bd2d55..cae33033e9 100644
--- a/nscd/pwdcache.c
+++ b/nscd/pwdcache.c
@@ -242,8 +242,18 @@ addpwbyuid (struct database *db, int fd, request_header *req,
char *buffer = alloca (buflen);
struct passwd resultbuf;
struct passwd *pwd;
- uid_t uid = atol (key);
uid_t oldeuid = 0;
+ char *ep;
+ uid_t uid = strtoul ((char*) key, &ep, 10);
+
+ if (*(char*)key == '\0' || *ep != '\0') /* invalid numeric uid */
+ {
+ if (debug_level > 0)
+ dbg_log (_("Invalid numeric uid \"%s\"!"), (char *)key);
+
+ errno = EINVAL;
+ return;
+ }
if (debug_level > 0)
dbg_log (_("Haven't found \"%d\" in password cache!"), uid);