diff options
author | Denis Vlasenko <vda.linux@googlemail.com> | 2007-11-12 21:21:35 +0000 |
---|---|---|
committer | Denis Vlasenko <vda.linux@googlemail.com> | 2007-11-12 21:21:35 +0000 |
commit | 6df9e3c9a38095c0c56728a81926aca53d28733f (patch) | |
tree | 5eb8cacb756615d7137e281d6d0d187afc50d316 | |
parent | 059c91711f664927534246bd5c1d5e202fcf8e1d (diff) | |
download | busybox-w32-6df9e3c9a38095c0c56728a81926aca53d28733f.tar.gz busybox-w32-6df9e3c9a38095c0c56728a81926aca53d28733f.tar.bz2 busybox-w32-6df9e3c9a38095c0c56728a81926aca53d28733f.zip |
inetd: revert bogus fix for bug 1562; shrink inetd a bit
function old new delta
dupconfig 159 146 -13
getconfigent 1123 1073 -50
-rw-r--r-- | networking/inetd.c | 50 |
1 files changed, 15 insertions, 35 deletions
diff --git a/networking/inetd.c b/networking/inetd.c index 9c17c920c..d76b75d5a 100644 --- a/networking/inetd.c +++ b/networking/inetd.c | |||
@@ -570,9 +570,8 @@ static void setup(servtab_t *sep) | |||
570 | static char *nextline(void) | 570 | static char *nextline(void) |
571 | { | 571 | { |
572 | char *cp; | 572 | char *cp; |
573 | FILE *fd = fconfig; | ||
574 | 573 | ||
575 | if (fgets(line, LINE_SIZE, fd) == NULL) | 574 | if (fgets(line, LINE_SIZE, fconfig) == NULL) |
576 | return NULL; | 575 | return NULL; |
577 | cp = strchr(line, '\n'); | 576 | cp = strchr(line, '\n'); |
578 | if (cp) | 577 | if (cp) |
@@ -586,7 +585,7 @@ static char *skip(char **cpp) /* int report; */ | |||
586 | char *start; | 585 | char *start; |
587 | 586 | ||
588 | /* erp: */ | 587 | /* erp: */ |
589 | if (*cpp == NULL) { | 588 | if (cp == NULL) { |
590 | /* if (report) */ | 589 | /* if (report) */ |
591 | /* bb_error_msg("syntax error in inetd config file"); */ | 590 | /* bb_error_msg("syntax error in inetd config file"); */ |
592 | return NULL; | 591 | return NULL; |
@@ -596,9 +595,7 @@ static char *skip(char **cpp) /* int report; */ | |||
596 | while (*cp == ' ' || *cp == '\t') | 595 | while (*cp == ' ' || *cp == '\t') |
597 | cp++; | 596 | cp++; |
598 | if (*cp == '\0') { | 597 | if (*cp == '\0') { |
599 | int c; | 598 | int c = getc(fconfig); |
600 | |||
601 | c = getc(fconfig); | ||
602 | ungetc(c, fconfig); | 599 | ungetc(c, fconfig); |
603 | if (c == ' ' || c == '\t') { | 600 | if (c == ' ' || c == '\t') { |
604 | cp = nextline(); | 601 | cp = nextline(); |
@@ -606,7 +603,6 @@ static char *skip(char **cpp) /* int report; */ | |||
606 | goto again; | 603 | goto again; |
607 | } | 604 | } |
608 | *cpp = NULL; | 605 | *cpp = NULL; |
609 | /* goto erp; */ | ||
610 | return NULL; | 606 | return NULL; |
611 | } | 607 | } |
612 | start = cp; | 608 | start = cp; |
@@ -614,8 +610,6 @@ static char *skip(char **cpp) /* int report; */ | |||
614 | cp++; | 610 | cp++; |
615 | if (*cp != '\0') | 611 | if (*cp != '\0') |
616 | *cp++ = '\0'; | 612 | *cp++ = '\0'; |
617 | /* if ((*cpp = cp) == NULL) */ | ||
618 | /* goto erp; */ | ||
619 | 613 | ||
620 | *cpp = cp; | 614 | *cpp = cp; |
621 | return start; | 615 | return start; |
@@ -623,7 +617,7 @@ static char *skip(char **cpp) /* int report; */ | |||
623 | 617 | ||
624 | static servtab_t *new_servtab(void) | 618 | static servtab_t *new_servtab(void) |
625 | { | 619 | { |
626 | return xmalloc(sizeof(servtab_t)); | 620 | return xzalloc(sizeof(servtab_t)); |
627 | } | 621 | } |
628 | 622 | ||
629 | static servtab_t *dupconfig(servtab_t *sep) | 623 | static servtab_t *dupconfig(servtab_t *sep) |
@@ -632,7 +626,6 @@ static servtab_t *dupconfig(servtab_t *sep) | |||
632 | int argc; | 626 | int argc; |
633 | 627 | ||
634 | newtab = new_servtab(); | 628 | newtab = new_servtab(); |
635 | memset(newtab, 0, sizeof(servtab_t)); | ||
636 | newtab->se_service = xstrdup(sep->se_service); | 629 | newtab->se_service = xstrdup(sep->se_service); |
637 | newtab->se_socktype = sep->se_socktype; | 630 | newtab->se_socktype = sep->se_socktype; |
638 | newtab->se_family = sep->se_family; | 631 | newtab->se_family = sep->se_family; |
@@ -668,17 +661,14 @@ static servtab_t *getconfigent(void) | |||
668 | 661 | ||
669 | sep = new_servtab(); | 662 | sep = new_servtab(); |
670 | 663 | ||
671 | /* memset(sep, 0, sizeof *sep); */ | ||
672 | more: | 664 | more: |
673 | /* freeconfig(sep); */ | 665 | while ((cp = nextline()) && *cp == '#') |
674 | 666 | continue; /* skip comment lines */ | |
675 | while ((cp = nextline()) && *cp == '#') /* skip comment line */; | ||
676 | if (cp == NULL) { | 667 | if (cp == NULL) { |
677 | /* free(sep); */ | 668 | free(sep); |
678 | return NULL; | 669 | return NULL; |
679 | } | 670 | } |
680 | 671 | ||
681 | memset((char *) sep, 0, sizeof *sep); | ||
682 | arg = skip(&cp); | 672 | arg = skip(&cp); |
683 | if (arg == NULL) { | 673 | if (arg == NULL) { |
684 | /* A blank line. */ | 674 | /* A blank line. */ |
@@ -776,9 +766,7 @@ static servtab_t *getconfigent(void) | |||
776 | } else | 766 | } else |
777 | sep->se_max = toomany; | 767 | sep->se_max = toomany; |
778 | } | 768 | } |
779 | sep->se_wait = strcmp(arg, "wait") == 0; | 769 | sep->se_wait = (strcmp(arg, "wait") == 0); |
780 | /* if ((arg = skip(&cp, 1)) == NULL) */ | ||
781 | /* goto more; */ | ||
782 | sep->se_user = xxstrdup(skip(&cp)); | 770 | sep->se_user = xxstrdup(skip(&cp)); |
783 | arg = strchr(sep->se_user, '.'); | 771 | arg = strchr(sep->se_user, '.'); |
784 | if (arg == NULL) | 772 | if (arg == NULL) |
@@ -788,10 +776,10 @@ static servtab_t *getconfigent(void) | |||
788 | sep->se_group = xstrdup(arg); | 776 | sep->se_group = xstrdup(arg); |
789 | } | 777 | } |
790 | 778 | ||
791 | arg = skip(&cp); | 779 | sep->se_server = xxstrdup(skip(&cp)); |
792 | sep->se_server = xxstrdup(arg); | ||
793 | if (strcmp(sep->se_server, "internal") == 0) { | ||
794 | #ifdef INETD_FEATURE_ENABLED | 780 | #ifdef INETD_FEATURE_ENABLED |
781 | /* sep->se_bi = NULL; - done by new_servtab() */ | ||
782 | if (strcmp(sep->se_server, "internal") == 0) { | ||
795 | const struct builtin *bi; | 783 | const struct builtin *bi; |
796 | 784 | ||
797 | for (bi = builtins; bi->bi_service; bi++) | 785 | for (bi = builtins; bi->bi_service; bi++) |
@@ -804,22 +792,14 @@ static servtab_t *getconfigent(void) | |||
804 | } | 792 | } |
805 | sep->se_bi = bi; | 793 | sep->se_bi = bi; |
806 | sep->se_wait = 0; /* = bi->bi_wait; - always 0 */ | 794 | sep->se_wait = 0; /* = bi->bi_wait; - always 0 */ |
807 | #else | ||
808 | bb_perror_msg("internal service %s unknown", sep->se_service); | ||
809 | goto more; | ||
810 | #endif | ||
811 | } | 795 | } |
812 | #ifdef INETD_FEATURE_ENABLED | ||
813 | else | ||
814 | sep->se_bi = NULL; | ||
815 | #endif | 796 | #endif |
816 | argc = 0; | 797 | argc = 0; |
817 | for (; cp; arg = skip(&cp)) { | 798 | while ((arg = skip(&cp)) != NULL && argc < MAXARGV) { |
818 | if (argc < MAXARGV) | 799 | sep->se_argv[argc++] = xxstrdup(arg); |
819 | sep->se_argv[argc++] = xxstrdup(arg); | ||
820 | } | 800 | } |
821 | while (argc <= MAXARGV) | 801 | /* while (argc <= MAXARGV) */ |
822 | sep->se_argv[argc++] = NULL; | 802 | /* sep->se_argv[argc++] = NULL; - done by new_servtab() */ |
823 | 803 | ||
824 | /* | 804 | /* |
825 | * Now that we've processed the entire line, check if the hostname | 805 | * Now that we've processed the entire line, check if the hostname |