summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBryan Cantrill <bryan@joyent.com>2016-06-07 23:40:08 +0000
committerRobert Mustacchi <rm@joyent.com>2016-08-22 21:37:14 -0700
commit7df3beae80fb29626950d633c57d859c12563bc8 (patch)
treeba0f29b18683e7cd0d2563ac10a4c0b8086f7d33
parent0343317a7b3df0798d9facd6eb5a0e83abd23d83 (diff)
downloadillumos-joyent-7df3beae80fb29626950d633c57d859c12563bc8.tar.gz
7270 mdb can die on divide overflow
Reviewed by: Robert Mustacchi <rm@joyent.com> Reviewed by: Patrick Mooney <patrick.mooney@joyent.com> Reviewed by: Jason King <jason.brian.king@gmail.com> Approved by: Gordon Ross <gordon.w.ross@gmail.com>
-rw-r--r--usr/src/cmd/mdb/common/mdb/mdb_grammar.y11
1 files changed, 10 insertions, 1 deletions
diff --git a/usr/src/cmd/mdb/common/mdb/mdb_grammar.y b/usr/src/cmd/mdb/common/mdb/mdb_grammar.y
index eda38203e5..97ea454627 100644
--- a/usr/src/cmd/mdb/common/mdb/mdb_grammar.y
+++ b/usr/src/cmd/mdb/common/mdb/mdb_grammar.y
@@ -25,7 +25,9 @@
* Use is subject to license terms.
*/
-#pragma ident "%Z%%M% %I% %E% SMI"
+/*
+ * Copyright (c) 2015, Joyent, Inc. All rights reserved.
+ */
#include <mdb/mdb_types.h>
#include <mdb/mdb_debug.h>
@@ -297,6 +299,13 @@ expression: expression '+' expression { $$ = $1 + $3; }
if ($3 == 0UL)
yyerror("attempted to divide by zero");
+ /*
+ * Annoyingly, x86 generates a #DE when dividing
+ * LONG_MIN by -1; check for this case explicitly.
+ */
+ if ($1 == LONG_MIN && $3 == -1L)
+ yyerror("divide overflow");
+
$$ = (intmax_t)$1 / (intmax_t)$3;
}