summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBryan Cantrill <bryan@joyent.com>2016-06-07 23:40:08 +0000
committerBryan Cantrill <bryan@joyent.com>2016-06-07 23:40:08 +0000
commitfda7c28f8bd3f34cbd1984a3414926dbff940eea (patch)
treeb674ba83805830072d9057fc593dd43e9151c97e
parent8a5ff7873220bd2725876b6ef7fdd2bceff60dd3 (diff)
downloadillumos-joyent-release-20160609.tar.gz
OS-5455 mdb can die on divide overflowrelease-20160609
Reviewed by: Robert Mustacchi <rm@joyent.com> Reviewed by: Patrick Mooney <patrick.mooney@joyent.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;
}