[libcxxabi] r307941 - [demangler] Respect try_to_parse_template_args
Erik Pilkington via cfe-commits
cfe-commits at lists.llvm.org
Thu Jul 13 12:37:38 PDT 2017
Author: epilk
Date: Thu Jul 13 12:37:37 2017
New Revision: 307941
URL: http://llvm.org/viewvc/llvm-project?rev=307941&view=rev
Log:
[demangler] Respect try_to_parse_template_args
Fixes an exponential parse found by oss-fuzz.
Modified:
libcxxabi/trunk/src/cxa_demangle.cpp
libcxxabi/trunk/test/test_demangle.pass.cpp
Modified: libcxxabi/trunk/src/cxa_demangle.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/src/cxa_demangle.cpp?rev=307941&r1=307940&r2=307941&view=diff
==============================================================================
--- libcxxabi/trunk/src/cxa_demangle.cpp (original)
+++ libcxxabi/trunk/src/cxa_demangle.cpp Thu Jul 13 12:37:37 2017
@@ -2364,17 +2364,20 @@ parse_type(const char* first, const char
first = t;
// Parsed a substitution. If the substitution is a
// <template-param> it might be followed by <template-args>.
- t = parse_template_args(first, last, db);
- if (t != first)
+ if (db.try_to_parse_template_args)
{
- if (db.names.size() < 2)
- return first;
- auto template_args = db.names.back().move_full();
- db.names.pop_back();
- db.names.back().first += template_args;
- // Need to create substitution for <template-template-param> <template-args>
- db.subs.push_back(Db::sub_type(1, db.names.back(), db.names.get_allocator()));
- first = t;
+ t = parse_template_args(first, last, db);
+ if (t != first)
+ {
+ if (db.names.size() < 2)
+ return first;
+ auto template_args = db.names.back().move_full();
+ db.names.pop_back();
+ db.names.back().first += template_args;
+ // Need to create substitution for <template-template-param> <template-args>
+ db.subs.push_back(Db::sub_type(1, db.names.back(), db.names.get_allocator()));
+ first = t;
+ }
}
}
}
Modified: libcxxabi/trunk/test/test_demangle.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/test/test_demangle.pass.cpp?rev=307941&r1=307940&r2=307941&view=diff
==============================================================================
--- libcxxabi/trunk/test/test_demangle.pass.cpp (original)
+++ libcxxabi/trunk/test/test_demangle.pass.cpp Thu Jul 13 12:37:37 2017
@@ -29669,6 +29669,7 @@ const char* invalid_cases[] =
"_ZcvCiIJEEDvT__FFFFT_vT_v",
"Z1JIJ1_T_EE3o00EUlT_E0",
"___Z2i_D1D1D1D1D1D1D1D1D1D1D1D1D1D1D1D1D1D1D1D1D1D1D1D1D1D1D1D1D1D",
+ "ZcvSdIZcvSdIZcvSdIZcvSdIZcvSdIZcvSdIDv_ZcvSdIZcvSdIZcvSdIZcvSdIZcvSdIZcvSdIDv_ZcvSdIZcvSdIZcvSdIZcvSdIZcvSdIZcvSdIDv_Dv_Dv_Dv_Dv_dZcvSdIZcvSdIZcvSdIZcvSdIZcvSdIZcvSdIDv_ZcvSdIZcvSdIZcvSdIZcvSdIZcvSdIZcvSdIDv_ZcvSdIZcvSdIZcvSdIZcvSdIZcvSdIZcvSdIDv_Dv_Dv_Dv_Dv_d",
};
const unsigned NI = sizeof(invalid_cases) / sizeof(invalid_cases[0]);
More information about the cfe-commits
mailing list