1
0
mirror of https://github.com/openbsd/src.git synced 2024-12-21 23:18:00 -08:00

Some atoi -> strtonum conversions; ok denis

This commit is contained in:
deraadt 2024-11-04 11:12:52 +00:00
parent 8fcde36223
commit 6b5bf2e84b
3 changed files with 25 additions and 12 deletions

View File

@ -1,4 +1,4 @@
/* $OpenBSD: chat.c,v 1.38 2024/08/17 15:42:20 denis Exp $ */
/* $OpenBSD: chat.c,v 1.39 2024/11/04 11:12:52 deraadt Exp $ */
/*
* Chat -- a program for automatic session establishment (i.e. dial
@ -213,6 +213,7 @@ int main(int, char *[]);
int
main(int argc, char **argv)
{
const char *errstr;
int option;
tzset();
@ -245,7 +246,9 @@ main(int argc, char **argv)
break;
case 't':
timeout = atoi(optarg);
timeout = strtonum(optarg, 0, 10000, &errstr);
if (errstr)
fatal(2, "-t %s: %s\n", optarg, errstr);
break;
case 'r':
@ -949,6 +952,8 @@ char *character(int c)
*/
void chat_send (char *s)
{
const char *errstr;
if (say_next) {
say_next = 0;
s = clean(s,0);
@ -1076,8 +1081,11 @@ void chat_send (char *s)
if (timeout_next) {
timeout_next = 0;
timeout = atoi(s);
timeout = strtonum(s, -1, 10000, &errstr);
if (errstr) {
logmsg("invalid timeout %s: %s\n", s, errstr);
timeout = -1;
}
if (timeout <= 0)
timeout = DEFAULT_CHAT_TIMEOUT;

View File

@ -1,4 +1,4 @@
/* $OpenBSD: pppstats.c,v 1.14 2024/08/10 05:32:28 jsg Exp $ */
/* $OpenBSD: pppstats.c,v 1.15 2024/11/04 11:12:52 deraadt Exp $ */
/*
* print PPP statistics:
@ -305,6 +305,7 @@ intpr(void)
int
main(int argc, char *argv[])
{
const char *errstr;
int c;
struct ifreq ifr;
@ -328,13 +329,13 @@ main(int argc, char *argv[])
zflag = 1;
break;
case 'c':
count = atoi(optarg);
if (count <= 0)
count = strtonum(optarg, 1, 1000, &errstr);
if (errstr)
usage();
break;
case 'w':
interval = atoi(optarg);
if (interval <= 0)
interval = strtonum(optarg, 1, 1000, &errstr);
if (errstr)
usage();
break;
default:

View File

@ -1,4 +1,4 @@
/* $OpenBSD: sys-bsd.c,v 1.36 2024/08/17 09:52:11 denis Exp $ */
/* $OpenBSD: sys-bsd.c,v 1.37 2024/11/04 11:12:52 deraadt Exp $ */
/*
* sys-bsd.c - System-dependent procedures for setting up
@ -1409,6 +1409,7 @@ GetMask(u_int32_t addr)
int
lock(char *dev)
{
const char *errstr;
char hdb_lock_buffer[12];
int fd, n;
pid_t pid;
@ -1429,8 +1430,11 @@ lock(char *dev)
close(fd);
} else {
hdb_lock_buffer[n] = 0;
pid = atoi(hdb_lock_buffer);
if (kill(pid, 0) == -1 && errno == ESRCH) {
pid = strtonum(hdb_lock_buffer, 1, 65535, &errstr);
if (errstr)
syslog(LOG_NOTICE, "lock file %s contains garbage: %s\n",
dev, errstr);
else if (kill(pid, 0) == -1 && errno == ESRCH) {
/* pid no longer exists - remove the lock file */
if (unlink(lock_file) == 0) {
close(fd);