#endif
/* options */
-static unsigned option_mask;
/* Correct regardless of combination of CONFIG_xxx */
enum {
OPTBIT_mark = 0, // -m
fl.l_len = 1;
#ifdef CONFIG_FEATURE_IPC_SYSLOG
- if ((option_mask & OPT_circularlog) && shbuf) {
+ if ((option_mask32 & OPT_circularlog) && shbuf) {
char b[1024];
va_start(arguments, fmt);
/* todo: supress duplicates */
#ifdef CONFIG_FEATURE_REMOTE_LOG
- if (option_mask & OPT_remotelog) {
+ if (option_mask32 & OPT_remotelog) {
char line[MAXLINE + 1];
/* trying connect the socket */
if (-1 == remotefd) {
}
}
- if (option_mask & OPT_locallog)
+ if (option_mask32 & OPT_locallog)
#endif
{
/* now spew out the message to wherever it is supposed to go */
if (pri == 0 || LOG_PRI(pri) < logLevel) {
- if (option_mask & OPT_small)
+ if (option_mask32 & OPT_small)
message("%s %s\n", timestamp, msg);
else
message("%s %s %s %s\n", timestamp, LocalHostName, res, msg);
if (chmod(lfile, 0666) < 0) {
bb_perror_msg_and_die("cannot set permission on %s", lfile);
}
- if (ENABLE_FEATURE_IPC_SYSLOG && (option_mask & OPT_circularlog)) {
+ if (ENABLE_FEATURE_IPC_SYSLOG && (option_mask32 & OPT_circularlog)) {
ipcsyslog_init();
}
char *p;
/* do normal option parsing */
- option_mask = bb_getopt_ulflags(argc, argv, OPTION_STR, OPTION_PARAM);
- if (option_mask & OPT_mark) MarkInterval = atoi(opt_m) * 60; // -m
- //if (option_mask & OPT_nofork) // -n
- //if (option_mask & OPT_outfile) // -O
- if (option_mask & OPT_loglevel) { // -l
- logLevel = atoi(opt_l);
+ getopt32(argc, argv, OPTION_STR, OPTION_PARAM);
+ 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 = xatoi_u(opt_l);
/* Valid levels are between 1 and 8 */
if (logLevel < 1 || logLevel > 8)
bb_show_usage();
}
- //if (option_mask & OPT_small) // -S
+ //if (option_mask32 & OPT_small) // -S
#if ENABLE_FEATURE_ROTATE_LOGFILE
- if (option_mask & OPT_filesize) logFileSize = atoi(opt_s) * 1024; // -s
- if (option_mask & OPT_rotatecnt) { // -b
- logFileRotate = atoi(opt_b);
+ if (option_mask32 & OPT_filesize) logFileSize = xatoul_range(opt_s, 0, INT_MAX/1024) * 1024; // -s
+ if (option_mask32 & OPT_rotatecnt) { // -b
+ logFileRotate = xatoi_u(opt_b);
if (logFileRotate > 99) logFileRotate = 99;
}
#endif
#if ENABLE_FEATURE_REMOTE_LOG
- if (option_mask & OPT_remotelog) { // -R
+ if (option_mask32 & OPT_remotelog) { // -R
int port = 514;
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;
remoteaddr.sin_port = htons(port);
free(host);
}
- //if (option_mask & OPT_locallog) // -L
+ //if (option_mask32 & OPT_locallog) // -L
#endif
#if ENABLE_FEATURE_IPC_SYSLOG
- if (option_mask & OPT_circularlog) { // -C
+ 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
/* If they have not specified remote logging, then log locally */
- if (ENABLE_FEATURE_REMOTE_LOG && !(option_mask & OPT_remotelog))
- option_mask |= OPT_locallog;
+ if (ENABLE_FEATURE_REMOTE_LOG && !(option_mask32 & OPT_remotelog))
+ option_mask32 |= OPT_locallog;
/* Store away localhost's name before the fork */
gethostname(LocalHostName, sizeof(LocalHostName));
umask(0);
- if (!(option_mask & OPT_nofork)) {
+ if (!(option_mask32 & OPT_nofork)) {
#ifdef BB_NOMMU
vfork_daemon_rexec(0, 1, argc, argv, "-n");
#else