diff options
author | Denis Vlasenko <vda.linux@googlemail.com> | 2006-10-08 12:49:22 +0000 |
---|---|---|
committer | Denis Vlasenko <vda.linux@googlemail.com> | 2006-10-08 12:49:22 +0000 |
commit | 1385899416a4396385ad421ae1f532be7103738a (patch) | |
tree | fc4d14a910593d1235318bb36abe5e9f72d2039e /networking/inetd.c | |
parent | 5625415085e68ac5e150f54e685417c866620d76 (diff) | |
download | busybox-w32-1385899416a4396385ad421ae1f532be7103738a.tar.gz busybox-w32-1385899416a4396385ad421ae1f532be7103738a.tar.bz2 busybox-w32-1385899416a4396385ad421ae1f532be7103738a.zip |
attempt to regularize atoi mess.
Diffstat (limited to 'networking/inetd.c')
-rw-r--r-- | networking/inetd.c | 29 |
1 files changed, 10 insertions, 19 deletions
diff --git a/networking/inetd.c b/networking/inetd.c index e22115a5c..966425385 100644 --- a/networking/inetd.c +++ b/networking/inetd.c | |||
@@ -149,8 +149,6 @@ | |||
149 | #define _PATH_INETDPID "/var/run/inetd.pid" | 149 | #define _PATH_INETDPID "/var/run/inetd.pid" |
150 | 150 | ||
151 | 151 | ||
152 | #define TOOMANY 0 /* don't start more than TOOMANY */ | ||
153 | |||
154 | #define CNT_INTVL 60 /* servers in CNT_INTVL sec. */ | 152 | #define CNT_INTVL 60 /* servers in CNT_INTVL sec. */ |
155 | #define RETRYTIME (60*10) /* retry after bind or server fail */ | 153 | #define RETRYTIME (60*10) /* retry after bind or server fail */ |
156 | 154 | ||
@@ -297,7 +295,7 @@ static const struct builtin builtins[] = { | |||
297 | static int global_queuelen = 128; | 295 | static int global_queuelen = 128; |
298 | static int nsock, maxsock; | 296 | static int nsock, maxsock; |
299 | static fd_set allsock; | 297 | static fd_set allsock; |
300 | static int toomany = TOOMANY; | 298 | static int toomany; |
301 | static int timingout; | 299 | static int timingout; |
302 | static struct servent *sp; | 300 | static struct servent *sp; |
303 | static uid_t uid; | 301 | static uid_t uid; |
@@ -588,10 +586,10 @@ static servtab_t *getconfigent(void) | |||
588 | sep = new_servtab(); | 586 | sep = new_servtab(); |
589 | 587 | ||
590 | /* memset(sep, 0, sizeof *sep); */ | 588 | /* memset(sep, 0, sizeof *sep); */ |
591 | more: | 589 | more: |
592 | /* freeconfig(sep); */ | 590 | /* freeconfig(sep); */ |
593 | 591 | ||
594 | while ((cp = nextline()) && *cp == '#'); | 592 | while ((cp = nextline()) && *cp == '#') /* skip comment line */; |
595 | if (cp == NULL) { | 593 | if (cp == NULL) { |
596 | /* free(sep); */ | 594 | /* free(sep); */ |
597 | return NULL; | 595 | return NULL; |
@@ -680,7 +678,7 @@ more: | |||
680 | } else if (*ccp != '\0') | 678 | } else if (*ccp != '\0') |
681 | goto badafterall; | 679 | goto badafterall; |
682 | #else | 680 | #else |
683 | bb_error_msg("%s: rpc services not supported", sep->se_service); | 681 | bb_error_msg("%s: rpc services not supported", sep->se_service); |
684 | #endif | 682 | #endif |
685 | } | 683 | } |
686 | } | 684 | } |
@@ -692,7 +690,7 @@ more: | |||
692 | char *s = strchr(arg, '.'); | 690 | char *s = strchr(arg, '.'); |
693 | if (s) { | 691 | if (s) { |
694 | *s++ = '\0'; | 692 | *s++ = '\0'; |
695 | sep->se_max = atoi(s); | 693 | sep->se_max = xatoi(s); |
696 | } else | 694 | } else |
697 | sep->se_max = toomany; | 695 | sep->se_max = toomany; |
698 | } | 696 | } |
@@ -928,7 +926,7 @@ static void config(int sig ATTRIBUTE_UNUSED) | |||
928 | */ | 926 | */ |
929 | if ( | 927 | if ( |
930 | #ifdef INETD_FEATURE_ENABLED | 928 | #ifdef INETD_FEATURE_ENABLED |
931 | cp->se_bi == 0 && | 929 | cp->se_bi == 0 && |
932 | #endif | 930 | #endif |
933 | (sep->se_wait == 1 || cp->se_wait == 0)) | 931 | (sep->se_wait == 1 || cp->se_wait == 0)) |
934 | sep->se_wait = cp->se_wait; | 932 | sep->se_wait = cp->se_wait; |
@@ -974,7 +972,7 @@ static void config(int sig ATTRIBUTE_UNUSED) | |||
974 | #ifdef CONFIG_FEATURE_INETD_RPC | 972 | #ifdef CONFIG_FEATURE_INETD_RPC |
975 | if (isrpcservice(sep)) { | 973 | if (isrpcservice(sep)) { |
976 | struct rpcent *rp; | 974 | struct rpcent *rp; |
977 | 975 | // FIXME: atoi_or_else(str, 0) would be handy here | |
978 | sep->se_rpcprog = atoi(sep->se_service); | 976 | sep->se_rpcprog = atoi(sep->se_service); |
979 | if (sep->se_rpcprog == 0) { | 977 | if (sep->se_rpcprog == 0) { |
980 | rp = getrpcbyname(sep->se_service); | 978 | rp = getrpcbyname(sep->se_service); |
@@ -990,9 +988,9 @@ static void config(int sig ATTRIBUTE_UNUSED) | |||
990 | register_rpc(sep); | 988 | register_rpc(sep); |
991 | } else | 989 | } else |
992 | #endif | 990 | #endif |
993 | { | 991 | { |
994 | u_short port = htons(atoi(sep->se_service)); | 992 | u_short port = htons(atoi(sep->se_service)); |
995 | 993 | // FIXME: atoi_or_else(str, 0) would be handy here | |
996 | if (!port) { | 994 | if (!port) { |
997 | /*XXX*/ strncpy(protoname, sep->se_proto, sizeof(protoname)); | 995 | /*XXX*/ strncpy(protoname, sep->se_proto, sizeof(protoname)); |
998 | if (isdigit(protoname[strlen(protoname) - 1])) | 996 | if (isdigit(protoname[strlen(protoname) - 1])) |
@@ -1255,13 +1253,7 @@ inetd_main(int argc, char *argv[]) | |||
1255 | 1253 | ||
1256 | opt = getopt32(argc, argv, "R:f", &stoomany); | 1254 | opt = getopt32(argc, argv, "R:f", &stoomany); |
1257 | if(opt & 1) { | 1255 | if(opt & 1) { |
1258 | char *e; | 1256 | toomany = xatoi_u(stoomany); |
1259 | |||
1260 | toomany = strtoul(stoomany, &e, 0); | ||
1261 | if (!(toomany >= 0 && *e == '\0')) { | ||
1262 | toomany = TOOMANY; | ||
1263 | bb_perror_msg("-R %s: bad value for service invocation rate", stoomany); | ||
1264 | } | ||
1265 | } | 1257 | } |
1266 | argc -= optind; | 1258 | argc -= optind; |
1267 | argv += optind; | 1259 | argv += optind; |
@@ -1317,7 +1309,6 @@ inetd_main(int argc, char *argv[]) | |||
1317 | sigaddset(&sa.sa_mask, SIGHUP); | 1309 | sigaddset(&sa.sa_mask, SIGHUP); |
1318 | sa.sa_handler = retry; | 1310 | sa.sa_handler = retry; |
1319 | sigaction(SIGALRM, &sa, NULL); | 1311 | sigaction(SIGALRM, &sa, NULL); |
1320 | /* doconfig(); */ | ||
1321 | config(SIGHUP); | 1312 | config(SIGHUP); |
1322 | sa.sa_handler = config; | 1313 | sa.sa_handler = config; |
1323 | sigaction(SIGHUP, &sa, NULL); | 1314 | sigaction(SIGHUP, &sa, NULL); |