diff options
author | Jilles Tjoelker <jilles@FreeBSD.org> | 2011-02-12 23:44:05 +0000 |
---|---|---|
committer | Jilles Tjoelker <jilles@FreeBSD.org> | 2011-02-12 23:44:05 +0000 |
commit | e9749129ad1308d4ccc1ec9520d62539931c3ae7 (patch) | |
tree | cc8681e662bed68e4af8833df6725164bd71882d /bin/sh/arith_yacc.c | |
parent | 0a70456882e4b46d78218f9c484dc739e6f272b5 (diff) | |
download | src-e9749129ad1308d4ccc1ec9520d62539931c3ae7.tar.gz src-e9749129ad1308d4ccc1ec9520d62539931c3ae7.zip |
sh: Detect dividing the smallest integer by -1.
This overflows and on some architectures such as amd64 it generates SIGFPE.
Generate an error on all architectures.
Notes
Notes:
svn path=/head/; revision=218626
Diffstat (limited to 'bin/sh/arith_yacc.c')
-rw-r--r-- | bin/sh/arith_yacc.c | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/bin/sh/arith_yacc.c b/bin/sh/arith_yacc.c index 423e4e256c10..8aab8fbcb1a3 100644 --- a/bin/sh/arith_yacc.c +++ b/bin/sh/arith_yacc.c @@ -125,6 +125,8 @@ static arith_t do_binop(int op, arith_t a, arith_t b) case ARITH_DIV: if (!b) yyerror("division by zero"); + if (a == ARITH_MIN && b == -1) + yyerror("divide error"); return op == ARITH_REM ? a % b : a / b; case ARITH_MUL: return a * b; |