diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2018-04-23 10:53:18 +0200 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2018-04-23 10:53:18 +0200 |
commit | 2454e678cb7d241097ee9ce4b2114a136f1b57ec (patch) | |
tree | e5a3a5667962c73f43ee8024a2a9152fd45b9577 /editors | |
parent | c21dfaf836cf0eb5317035bc20395c751a205934 (diff) | |
download | busybox-w32-2454e678cb7d241097ee9ce4b2114a136f1b57ec.tar.gz busybox-w32-2454e678cb7d241097ee9ce4b2114a136f1b57ec.tar.bz2 busybox-w32-2454e678cb7d241097ee9ce4b2114a136f1b57ec.zip |
awk: do not allow $(-1)
function old new delta
EMSG_NEGATIVE_FIELD - 25 +25
evaluate 3390 3403 +13
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 1/0 up/down: 38/0) Total: 38 bytes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'editors')
-rw-r--r-- | editors/awk.c | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/editors/awk.c b/editors/awk.c index d54249bfd..bafc9ba1d 100644 --- a/editors/awk.c +++ b/editors/awk.c | |||
@@ -598,6 +598,7 @@ static const char EMSG_NOT_ARRAY[] ALIGN1 = "Not an array"; | |||
598 | static const char EMSG_POSSIBLE_ERROR[] ALIGN1 = "Possible syntax error"; | 598 | static const char EMSG_POSSIBLE_ERROR[] ALIGN1 = "Possible syntax error"; |
599 | static const char EMSG_UNDEF_FUNC[] ALIGN1 = "Call to undefined function"; | 599 | static const char EMSG_UNDEF_FUNC[] ALIGN1 = "Call to undefined function"; |
600 | static const char EMSG_NO_MATH[] ALIGN1 = "Math support is not compiled in"; | 600 | static const char EMSG_NO_MATH[] ALIGN1 = "Math support is not compiled in"; |
601 | static const char EMSG_NEGATIVE_FIELD[] ALIGN1 = "Access to negative field"; | ||
601 | 602 | ||
602 | static void zero_out_var(var *vp) | 603 | static void zero_out_var(var *vp) |
603 | { | 604 | { |
@@ -2949,6 +2950,8 @@ static var *evaluate(node *op, var *res) | |||
2949 | 2950 | ||
2950 | case XC( OC_FIELD ): { | 2951 | case XC( OC_FIELD ): { |
2951 | int i = (int)getvar_i(R.v); | 2952 | int i = (int)getvar_i(R.v); |
2953 | if (i < 0) | ||
2954 | syntax_error(EMSG_NEGATIVE_FIELD); | ||
2952 | if (i == 0) { | 2955 | if (i == 0) { |
2953 | res = intvar[F0]; | 2956 | res = intvar[F0]; |
2954 | } else { | 2957 | } else { |