aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2015-03-03 13:10:30 +0100
committerDenys Vlasenko <vda.linux@googlemail.com>2015-03-03 13:10:30 +0100
commit2ec4f44225f18bc00732cac21f3fde9d3dc2f29f (patch)
treed269e1017864c50c4ec59dfa199e851615d5cd97
parent3aef814c0b08d9703280b4772060ce5016c683c4 (diff)
downloadbusybox-w32-2ec4f44225f18bc00732cac21f3fde9d3dc2f29f.tar.gz
busybox-w32-2ec4f44225f18bc00732cac21f3fde9d3dc2f29f.tar.bz2
busybox-w32-2ec4f44225f18bc00732cac21f3fde9d3dc2f29f.zip
inetd: fix order of array index check and array access
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r--networking/inetd.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/networking/inetd.c b/networking/inetd.c
index b3f2e9fbc..8148925ce 100644
--- a/networking/inetd.c
+++ b/networking/inetd.c
@@ -645,7 +645,7 @@ static servtab_t *dup_servtab(servtab_t *sep)
645} 645}
646 646
647/* gcc generates much more code if this is inlined */ 647/* gcc generates much more code if this is inlined */
648static servtab_t *parse_one_line(void) 648static NOINLINE servtab_t *parse_one_line(void)
649{ 649{
650 int argc; 650 int argc;
651 char *token[6+MAXARGV]; 651 char *token[6+MAXARGV];
@@ -675,6 +675,8 @@ static servtab_t *parse_one_line(void)
675 * default host for the following lines. */ 675 * default host for the following lines. */
676 free(default_local_hostname); 676 free(default_local_hostname);
677 default_local_hostname = sep->se_local_hostname; 677 default_local_hostname = sep->se_local_hostname;
678 /*sep->se_local_hostname = NULL; - redundant */
679 /* (we'll overwrite this field anyway) */
678 goto more; 680 goto more;
679 } 681 }
680 } else 682 } else
@@ -688,10 +690,10 @@ static servtab_t *parse_one_line(void)
688 parse_err: 690 parse_err:
689 bb_error_msg("parse error on line %u, line is ignored", 691 bb_error_msg("parse error on line %u, line is ignored",
690 parser->lineno); 692 parser->lineno);
691 free_servtab_strings(sep);
692 /* Just "goto more" can make sep to carry over e.g. 693 /* Just "goto more" can make sep to carry over e.g.
693 * "rpc"-ness (by having se_rpcver_lo != 0). 694 * "rpc"-ness (by having se_rpcver_lo != 0).
694 * We will be more paranoid: */ 695 * We will be more paranoid: */
696 free_servtab_strings(sep);
695 free(sep); 697 free(sep);
696 goto new; 698 goto new;
697 } 699 }
@@ -815,7 +817,7 @@ static servtab_t *parse_one_line(void)
815 } 817 }
816#endif 818#endif
817 argc = 0; 819 argc = 0;
818 while ((arg = token[6+argc]) != NULL && argc < MAXARGV) 820 while (argc < MAXARGV && (arg = token[6+argc]) != NULL)
819 sep->se_argv[argc++] = xstrdup(arg); 821 sep->se_argv[argc++] = xstrdup(arg);
820 /* Some inetd.conf files have no argv's, not even argv[0]. 822 /* Some inetd.conf files have no argv's, not even argv[0].
821 * Fix them up. 823 * Fix them up.