chiark / gitweb /
Bugfix.
[userv.git] / client.c
index 527da1b9653baae800748653e6088d1aea2d5a30..68ec6a4d1b9ff68dafbd821f3bb3c3078016ba94 100644 (file)
--- a/client.c
+++ b/client.c
@@ -392,17 +392,20 @@ static void of_file(const struct optioninfo *oip, const char *value, char *key)
 
 static void of_fdwait(const struct optioninfo *oip, const char *value, char *key) {
   const struct fdmodifierinfo *fdmip;
-  unsigned long fd;
+  unsigned long ul;
+  int fd;
   char *delim;
   
   fd= fdstdnumber(key);
   if (fd<0) {
-    fd= strtoul(value,&delim,0);
+    ul= strtoul(key,&delim,0);
     if (*delim) usageerror("first part of argument to --fdwait must be "
                           "numeric or fd name - `%s' is not recognised",key);
+    if (ul>INT_MAX) usageerror("first part of argument to --fdwait is far too large");
+    fd= ul;
   }
   if (fd >= fdsetupsize || !fdsetup[fd].filename)
-    usageerror("file descriptor %lu specified in --fdwait option is not open",fd);
+    usageerror("file descriptor %d specified in --fdwait option is not open",fd);
   for (fdmip= fdmodifierinfos; fdmip->string && strcmp(fdmip->string,value); fdmip++);
   if (!fdmip->string || !(fdmip->implies & (fdm_wait|fdm_nowait|fdm_close)))
     usageerror("value for --fdwait must be `wait', `nowait' or `close', not `%s'",value);