Limit symbol length in demangle()
authorGiuseppe Ottaviano <ott@fb.com>
Fri, 29 Jul 2016 21:24:41 +0000 (14:24 -0700)
committerFacebook Github Bot 0 <facebook-github-bot-0-bot@fb.com>
Fri, 29 Jul 2016 21:38:32 +0000 (14:38 -0700)
commitacd8ed50ea0e493e97a9e28a5b145ee287ace0a2
treee07fe1afad6217ef0849817176acb6d9e818fa33
parent342ce9ee33b13a2b108b57724f92a98420862971
Limit symbol length in demangle()

Summary:
GCC's `__cxa_demangle()` uses on-stack data structures for the parser
state which are linear in the number of components of the symbol. For
extremely long symbols, this can cause a stack overflow.

This diff introduces an arbitrary symbol length limit above which we
just return the mangled name.

Reviewed By: philippv

Differential Revision: D3641115

fbshipit-source-id: ec360bb20ca499fd0eaf3a06c5bbcbd1e936d845
folly/Demangle.cpp
folly/test/DemangleTest.cpp