aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2012-03-08 03:50:01 +0100
committerDenys Vlasenko <vda.linux@googlemail.com>2012-03-08 03:50:01 +0100
commit07fcaab595e9029ebe37f5240a10038c493af545 (patch)
tree20e175ae2f5bd3534104e09f090524881799f95b
parentd98dc92d6a8bcc68287310c3e33a77efb9fcbe3b (diff)
downloadbusybox-w32-07fcaab595e9029ebe37f5240a10038c493af545.tar.gz
busybox-w32-07fcaab595e9029ebe37f5240a10038c493af545.tar.bz2
busybox-w32-07fcaab595e9029ebe37f5240a10038c493af545.zip
test: "test !" was accessing argv past NULL - fix it. Closes 4832
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r--coreutils/test.c15
1 files changed, 8 insertions, 7 deletions
diff --git a/coreutils/test.c b/coreutils/test.c
index 1f5398ad8..0bc008e7c 100644
--- a/coreutils/test.c
+++ b/coreutils/test.c
@@ -710,7 +710,8 @@ static number_t nexpr(enum token n)
710 if (n == EOI) { 710 if (n == EOI) {
711 /* special case: [ ! ], [ a -a ! ] are valid */ 711 /* special case: [ ! ], [ a -a ! ] are valid */
712 /* IOW, "! ARG" may miss ARG */ 712 /* IOW, "! ARG" may miss ARG */
713 unnest_msg("<nexpr:1 (!EOI)\n"); 713 args--;
714 unnest_msg("<nexpr:1 (!EOI), args:%s(%p)\n", args[0], &args[0]);
714 return 1; 715 return 1;
715 } 716 }
716 res = !nexpr(n); 717 res = !nexpr(n);
@@ -729,15 +730,15 @@ static number_t aexpr(enum token n)
729 730
730 nest_msg(">aexpr(%s)\n", TOKSTR[n]); 731 nest_msg(">aexpr(%s)\n", TOKSTR[n]);
731 res = nexpr(n); 732 res = nexpr(n);
732 dbg_msg("aexpr: nexpr:%lld, next args:%s\n", res, args[1]); 733 dbg_msg("aexpr: nexpr:%lld, next args:%s(%p)\n", res, args[1], &args[1]);
733 if (check_operator(*++args) == BAND) { 734 if (check_operator(*++args) == BAND) {
734 dbg_msg("aexpr: arg is AND, next args:%s\n", args[1]); 735 dbg_msg("aexpr: arg is AND, next args:%s(%p)\n", args[1], &args[1]);
735 res = aexpr(check_operator(*++args)) && res; 736 res = aexpr(check_operator(*++args)) && res;
736 unnest_msg("<aexpr:%lld\n", res); 737 unnest_msg("<aexpr:%lld\n", res);
737 return res; 738 return res;
738 } 739 }
739 args--; 740 args--;
740 unnest_msg("<aexpr:%lld, args:%s\n", res, args[0]); 741 unnest_msg("<aexpr:%lld, args:%s(%p)\n", res, args[0], &args[0]);
741 return res; 742 return res;
742} 743}
743 744
@@ -748,15 +749,15 @@ static number_t oexpr(enum token n)
748 749
749 nest_msg(">oexpr(%s)\n", TOKSTR[n]); 750 nest_msg(">oexpr(%s)\n", TOKSTR[n]);
750 res = aexpr(n); 751 res = aexpr(n);
751 dbg_msg("oexpr: aexpr:%lld, next args:%s\n", res, args[1]); 752 dbg_msg("oexpr: aexpr:%lld, next args:%s(%p)\n", res, args[1], &args[1]);
752 if (check_operator(*++args) == BOR) { 753 if (check_operator(*++args) == BOR) {
753 dbg_msg("oexpr: next arg is OR, next args:%s\n", args[1]); 754 dbg_msg("oexpr: next arg is OR, next args:%s(%p)\n", args[1], &args[1]);
754 res = oexpr(check_operator(*++args)) || res; 755 res = oexpr(check_operator(*++args)) || res;
755 unnest_msg("<oexpr:%lld\n", res); 756 unnest_msg("<oexpr:%lld\n", res);
756 return res; 757 return res;
757 } 758 }
758 args--; 759 args--;
759 unnest_msg("<oexpr:%lld, args:%s\n", res, args[0]); 760 unnest_msg("<oexpr:%lld, args:%s(%p)\n", res, args[0], &args[0]);
760 return res; 761 return res;
761} 762}
762 763