summaryrefslogtreecommitdiffstats
path: root/runtime/arith.c
diff options
context:
space:
mode:
authorhunt <hunt>2005-09-08 19:13:57 +0000
committerhunt <hunt>2005-09-08 19:13:57 +0000
commitded7c51403aaee14faa3c231d53177e2b90bea30 (patch)
tree0277780e3db9c1d0a7f01bea5a941c473273d2cc /runtime/arith.c
parent367e790dff1d5940e0e4ffa6fa4ce116d425626f (diff)
downloadsystemtap-steved-ded7c51403aaee14faa3c231d53177e2b90bea30.tar.gz
systemtap-steved-ded7c51403aaee14faa3c231d53177e2b90bea30.tar.xz
systemtap-steved-ded7c51403aaee14faa3c231d53177e2b90bea30.zip
2005-09-08 Martin Hunt <hunt@redhat.com>
* arith.c (_stp_div64): Check for overflow. (_stp_mod64): Ditto.
Diffstat (limited to 'runtime/arith.c')
-rw-r--r--runtime/arith.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/runtime/arith.c b/runtime/arith.c
index e9977718..ee75e4f8 100644
--- a/runtime/arith.c
+++ b/runtime/arith.c
@@ -1,6 +1,7 @@
/* -*- linux-c -*- */
/* Math functions
* Copyright (C) 2005 Red Hat Inc.
+ * Portions (C) Free Software Foundation, Inc.
*
* This file is part of systemtap, and is free software. You can
* redistribute it and/or modify it under the terms of the GNU General
@@ -30,8 +31,8 @@ long long _mod64 (long long u, long long v);
int64_t _stp_div64 (const char **error, int64_t x, int64_t y)
{
#ifdef __LP64__
- if (unlikely (y == 0)) {
- *error = "attempt to divide by 0";
+ if (unlikely (y == 0 || (x == LONG_MIN && y == -1))) {
+ *error = "divisor out of range";
return 0;
}
return x/y;
@@ -59,8 +60,8 @@ int64_t _stp_div64 (const char **error, int64_t x, int64_t y)
int64_t _stp_mod64 (const char **error, int64_t x, int64_t y)
{
#ifdef __LP64__
- if (unlikely (y == 0)) {
- *error = "attempt to divide by 0";
+ if (unlikely (y == 0 || (x == LONG_MIN && y == -1))) {
+ *error = "divisor out of range";
return 0;
}
return x%y;