From kde-commits Sun Jul 26 03:35:57 2009 From: Kevin Kofler Date: Sun, 26 Jul 2009 03:35:57 +0000 To: kde-commits Subject: branches/KDE/4.3/kdelibs/kjs Message-Id: <1248579357.957322.9209.nullmailer () svn ! kde ! org> X-MARC-Message: https://marc.info/?l=kde-commits&m=124857936818133 SVN commit 1002473 by kkofler: Fix integer overflow in KJS JavaScript garbage collector (CVE-2009-1687). Patch adapted from WebKit changeset 41854 by Geoffrey Garen. FIXME: This will still crash (as in the WebKit commit), so you can still DoS the browser, but at least the overflow is not exploitable anymore. Backport revision 1002471 from trunk. M +4 -0 collector.cpp --- branches/KDE/4.3/kdelibs/kjs/collector.cpp #1002472:1002473 @@ -31,6 +31,7 @@ #include "value.h" #include +#include #include #if PLATFORM(DARWIN) @@ -109,6 +110,9 @@ void append(CollectorBlock* block) { if (m_used == m_capacity) { + static const size_t maxNumBlocks = ULONG_MAX / sizeof(CollectorBlock*) / GROWTH_FACTOR; + if (m_capacity > maxNumBlocks) + CRASH(); m_capacity = max(MIN_ARRAY_SIZE, m_capacity * GROWTH_FACTOR); m_data = static_cast(fastRealloc(m_data, m_capacity * sizeof(CollectorBlock *))); }