Skip to content

Commit

Permalink
[gnuv2] Fix multiplication overflow check due compiler optimizations (#…
Browse files Browse the repository at this point in the history
…54)

Vulnerability found by @ifyGecko
  • Loading branch information
wargio committed Aug 13, 2023
1 parent 8734062 commit 51d0167
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/gnu_v2/cplus-dem.c
Expand Up @@ -420,7 +420,10 @@ static int
consume_count(type)
const char **type;
{
int count = 0;
// Note by RizinOrg:
// to prevent the overflow check to be optimized out
// by the compiler, this variable needs to be volatile.
volatile int count = 0;

if (!isdigit((unsigned char)**type))
return -1;
Expand Down
3 changes: 3 additions & 0 deletions test/test_cxx_gnu_v2.c
Expand Up @@ -4,6 +4,9 @@
#include "minunit.h"

mu_demangle_tests(gnu_v2,
// fuzzed strings
mu_demangle_test("_ITM_deregisterTMCCCCCCCCCCCCCCCCCCCtart__5555555555555555CloneTable", NULL),
// normal
mu_demangle_test("_vt.foo", "foo virtual table"),
mu_demangle_test("_vt$foo", "foo virtual table"),
mu_demangle_test("_vt$foo$bar", "foo::bar virtual table"),
Expand Down

0 comments on commit 51d0167

Please sign in to comment.