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