From 14f3c113d30700ab9fc466bb3ffce71f94de776b Mon Sep 17 00:00:00 2001 From: Anton Kochkov Date: Fri, 25 Apr 2014 04:18:14 +0400 Subject: [PATCH] Fix CID #1195065 --- libr/util/uleb128.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/libr/util/uleb128.c b/libr/util/uleb128.c index 169ca9414f..bf6916608c 100644 --- a/libr/util/uleb128.c +++ b/libr/util/uleb128.c @@ -23,8 +23,13 @@ R_API const ut8 *r_leb128 (const ut8 *data, st64 *v) { s += 7; if (!(c & 0x80)) break; } + /* FIXME: More proper sum calculation */ if ((s < (8 * sizeof (sum))) && (c & 0x40)) { - sum |= -(1 << s); + if (sum > 31) { + sum |= -(1 << s); + } else { + eprintf ("r_len128(): s is too big (>31) - undefined behaviour!\n"); + } } if (v) *v = sum; return data;