From 1385899416a4396385ad421ae1f532be7103738a Mon Sep 17 00:00:00 2001 From: Denis Vlasenko Date: Sun, 8 Oct 2006 12:49:22 +0000 Subject: attempt to regularize atoi mess. --- sysklogd/klogd.c | 3 +-- sysklogd/logger.c | 9 +++------ sysklogd/syslogd.c | 14 ++++++-------- 3 files changed, 10 insertions(+), 16 deletions(-) (limited to 'sysklogd') diff --git a/sysklogd/klogd.c b/sysklogd/klogd.c index e629bec5d..f735d9fc1 100644 --- a/sysklogd/klogd.c +++ b/sysklogd/klogd.c @@ -43,7 +43,6 @@ int klogd_main(int argc, char **argv) int i, n, lastc; char *start; - { unsigned opt; @@ -52,7 +51,7 @@ int klogd_main(int argc, char **argv) if (opt & OPT_LEVEL) { /* Valid levels are between 1 and 8 */ - console_log_level = bb_xgetlarg(start, 10, 1, 8); + console_log_level = xatoul_range(start, 1, 8); } if (!(opt & OPT_FOREGROUND)) { diff --git a/sysklogd/logger.c b/sysklogd/logger.c index 15a4bfb82..8901bd79f 100644 --- a/sysklogd/logger.c +++ b/sysklogd/logger.c @@ -48,14 +48,14 @@ static int decode(char *name, CODE * codetab) CODE *c; if (isdigit(*name)) - return (atoi(name)); + return atoi(name); for (c = codetab; c->c_name; c++) { if (!strcasecmp(name, c->c_name)) { - return (c->c_val); + return c->c_val; } } - return (-1); + return -1; } /* Decode a symbolic name to a numeric value @@ -177,6 +177,3 @@ int logger_main(int argc, char **argv) * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ - - - diff --git a/sysklogd/syslogd.c b/sysklogd/syslogd.c index 254d7e73c..9e030bd63 100644 --- a/sysklogd/syslogd.c +++ b/sysklogd/syslogd.c @@ -575,20 +575,20 @@ int syslogd_main(int argc, char **argv) /* do normal option parsing */ getopt32(argc, argv, OPTION_STR, OPTION_PARAM); - if (option_mask32 & OPT_mark) MarkInterval = atoi(opt_m) * 60; // -m + if (option_mask32 & OPT_mark) MarkInterval = xatoul_range(opt_m, 0, INT_MAX/60) * 60; // -m //if (option_mask32 & OPT_nofork) // -n //if (option_mask32 & OPT_outfile) // -O if (option_mask32 & OPT_loglevel) { // -l - logLevel = atoi(opt_l); + logLevel = xatoi_u(opt_l); /* Valid levels are between 1 and 8 */ if (logLevel < 1 || logLevel > 8) bb_show_usage(); } //if (option_mask32 & OPT_small) // -S #if ENABLE_FEATURE_ROTATE_LOGFILE - if (option_mask32 & OPT_filesize) logFileSize = atoi(opt_s) * 1024; // -s + if (option_mask32 & OPT_filesize) logFileSize = xatoul_range(opt_s, 0, INT_MAX/1024) * 1024; // -s if (option_mask32 & OPT_rotatecnt) { // -b - logFileRotate = atoi(opt_b); + logFileRotate = xatoi_u(opt_b); if (logFileRotate > 99) logFileRotate = 99; } #endif @@ -598,7 +598,7 @@ int syslogd_main(int argc, char **argv) char *host = xstrdup(opt_R); p = strchr(host, ':'); if (p) { - port = atoi(p + 1); + port = xatou16(p + 1); *p = '\0'; } remoteaddr.sin_family = AF_INET; @@ -612,9 +612,7 @@ int syslogd_main(int argc, char **argv) #if ENABLE_FEATURE_IPC_SYSLOG if (option_mask32 & OPT_circularlog) { // -C if (opt_C) { - int buf_size = atoi(opt_C); - if (buf_size >= 4) - shm_size = buf_size * 1024; + shm_size = xatoul_range(opt_C, 4, INT_MAX/1024) * 1024; } } #endif -- cgit v1.2.3