diff options
author | Bob Beck <beck@cvs.openbsd.org> | 2001-08-19 15:37:02 +0000 |
---|---|---|
committer | Bob Beck <beck@cvs.openbsd.org> | 2001-08-19 15:37:02 +0000 |
commit | 8bedaf3e878a9ce42f60cb97d32670c459497739 (patch) | |
tree | 1eb6c78bb12c786cb435be2a9afaab18abe6a289 /libexec/ftp-proxy/ftp-proxy.c | |
parent | c17aa3f3c4af121249f83c355dd6ec319782bfce (diff) |
bye bye atoi.
Diffstat (limited to 'libexec/ftp-proxy/ftp-proxy.c')
-rw-r--r-- | libexec/ftp-proxy/ftp-proxy.c | 29 |
1 files changed, 21 insertions, 8 deletions
diff --git a/libexec/ftp-proxy/ftp-proxy.c b/libexec/ftp-proxy/ftp-proxy.c index 62e0c43ce2c..dfb704d36a9 100644 --- a/libexec/ftp-proxy/ftp-proxy.c +++ b/libexec/ftp-proxy/ftp-proxy.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ftp-proxy.c,v 1.6 2001/08/19 15:19:28 beck Exp $ */ +/* $OpenBSD: ftp-proxy.c,v 1.7 2001/08/19 15:37:01 beck Exp $ */ /* * Copyright (c) 1996-2001 @@ -677,7 +677,7 @@ do_server_reply(struct csiob *server, struct csiob *client) { int code, i, j, rv; struct in_addr *iap; - char tbuf[100], *sendbuf; + char tbuf[100], *sendbuf, *p; log_control_command((char *)server->line_buffer, 0); @@ -694,7 +694,11 @@ do_server_reply(struct csiob *server, struct csiob *client) /* * Watch out for "227 Entering Passive Mode ..." replies */ - code = atoi((char *)server->line_buffer); + code = strtol((char *)server->line_buffer, &p, 10); + if (!*(server->line_buffer) || (*p != ' ' && *p != '-')) { + syslog(LOG_INFO, "malformed control reply"); + exit(EX_DATAERR); + } if (code <= 0 || code > 999) { syslog(LOG_INFO, "invalid server reply code %d", code); exit(EX_DATAERR); @@ -810,6 +814,7 @@ main(int argc, char **argv) int one = 1; while ((ch = getopt(argc, argv, argstr)) != -1) { + char *p; switch (ch) { case 'A': AnonFtpOnly = 1; /* restrict to anon usernames only */ @@ -821,10 +826,14 @@ main(int argc, char **argv) Verbose = 1; break; case 't': - timeout_seconds = atoi(optarg); + timeout_seconds = strtol(optarg, &p, 10); + if (!*optarg || *p) + usage(); break; case 'D': - Debug_Level = atoi(optarg); + Debug_Level = strtol(optarg, &p, 10); + if (!*optarg || *p) + usage(); break; case 'r': Use_Rdns = 1; /* look up hostnames */ @@ -833,13 +842,17 @@ main(int argc, char **argv) NatMode = 1; /* pass all passives, we're using NAT */ break; case 'm': - min_port = atoi(optarg); + min_port = strtol(optarg, &p, 10); + if (!*optarg || *p) + usage(); if (min_port < 0 || min_port > USHRT_MAX) usage(); break; case 'M': - max_port = atoi(optarg); - if (min_port < 0 || min_port > USHRT_MAX) + max_port = strtol(optarg, &p, 10); + if (!*optarg || *p) + usage(); + if (max_port < 0 || max_port > USHRT_MAX) usage(); break; default: |