diff options
-rw-r--r-- | runtime/ChangeLog | 4 | ||||
-rw-r--r-- | runtime/arith.c | 9 |
2 files changed, 9 insertions, 4 deletions
diff --git a/runtime/ChangeLog b/runtime/ChangeLog index a6e1393e..bbff766f 100644 --- a/runtime/ChangeLog +++ b/runtime/ChangeLog @@ -1,4 +1,8 @@ 2005-09-08 Martin Hunt <hunt@redhat.com> + * arith.c (_stp_div64): Check for overflow. + (_stp_mod64): Ditto. + +2005-09-08 Martin Hunt <hunt@redhat.com> * arith.c (_stp_div64): For 64-bit cpus, just use native division. Otherwise call _div64(). 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; |