~mdw
/
sgt
/
utils
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Adjust 'after' so that it tries more rigorously to parse the input
[sgt/utils]
/
after
/
after.c
diff --git
a/after/after.c
b/after/after.c
index
af8b3a5
..
eb74813
100644
(file)
--- a/
after/after.c
+++ b/
after/after.c
@@
-274,7
+274,14
@@
int main(int argc, char **argv)
fprintf(stderr, "%s: parameter `%s' unexpected\n", pname, p);
return 1;
} else {
fprintf(stderr, "%s: parameter `%s' unexpected\n", pname, p);
return 1;
} else {
- pid = atoi(p);
+ char *end;
+ errno = 0;
+ pid = strtol(p, &end, 0);
+ if (errno == ERANGE || *end || pid < 0) {
+ fprintf(stderr, "%s: unable to parse `%s' as a pid\n",
+ pname, p);
+ return 1;
+ }
}
}
}
}
}
}