Heap-buffer-overflow in nsHTMLEditor::IsPrevCharInNodeWhitespace
Originally disclosed on Mozilla
- Fixed in 5 days
- Paid in 11 months
- Disclosed after 5 days
Created attachment 655434 Testcase
Reproduces on trunk 20120825191419 http://hg.mozilla.org/mozilla-central/rev/e874475efe15
================================================================= ==30534== ERROR: AddressSanitizer heap-buffer-overflow on address 0x7f5f56a1dc9d at pc 0x7f5f78caed33 bp 0x7fffd1793670 sp 0x7fffd1793668 READ of size 1 at 0x7f5f56a1dc9d thread T0 #0 0x7f5f78caed32 in nsTextFragment::CharAt(int) const src/layout/base/../../content/base/src/nsTextFragment.h:178 #1 0x7f5f7ddfe7cf in nsHTMLEditor::IsPrevCharInNodeWhitespace(nsIContent*, int, bool*, bool*, nsIContent**, int*) src/editor/libeditor/html/nsHTMLEditor.cpp:901 #2 0x7f5f7dfe2654 in nsHTMLEditRules::GetPromotedPoint(nsHTMLEditRules::RulesEndpoint, nsIDOMNode*, int, EditAction, nsCOMPtr<nsIDOMNode>, int) src/editor/libeditor/html/nsHTMLEditRules.cpp:5240 #3 0x7f5f7def0402 in nsHTMLEditRules::PromoteRange(nsIDOMRange*, EditAction) src/editor/libeditor/html/nsHTMLEditRules.cpp:5492 #4 0x7f5f7deeaaa2 in nsHTMLEditRules::AfterEditInner(EditAction, short) src/editor/libeditor/html/nsHTMLEditRules.cpp:430 #5 0x7f5f7dee8d90 in nsHTMLEditRules::AfterEdit(EditAction, short) src/editor/libeditor/html/nsHTMLEditRules.cpp:376 #6 0x7f5f7de57aac in nsHTMLEditor::EndOperation() src/editor/libeditor/html/nsHTMLEditor.cpp:3513 #7 0x7f5f7d899f1c in ~nsAutoRules src/editor/libeditor/base/nsEditorUtils.h:95 #8 0x7f5f7d877ba2 in ~nsAutoRules src/editor/libeditor/base/nsEditorUtils.h:92 #9 0x7f5f7d87dafc in nsPlaintextEditor::InsertText(nsAString_internal const&) src/editor/libeditor/text/nsPlaintextEditor.cpp:728 #10 0x7f5f7d87df1e in non-virtual thunk to nsPlaintextEditor::InsertText(nsAString_internal const&) src/build/unix/stdc++compat/stdc++compat.cpp:0 #11 0x7f5f7d9995d8 in nsInsertPlaintextCommand::DoCommandParams(char const*, nsICommandParams*, nsISupports*) src/editor/libeditor/base/nsEditorCommands.cpp:846 #12 0x7f5f80c790d1 in nsControllerCommandTable::DoCommandParams(char const*, nsICommandParams*, nsISupports*) src/embedding/components/commandhandler/src/nsControllerCommandTable.cpp:175 #13 0x7f5f80c4c3a2 in nsBaseCommandController::DoCommandWithParams(char const*, nsICommandParams*) src/embedding/components/commandhandler/src/nsBaseCommandController.cpp:153 #14 0x7f5f80c4c676 in non-virtual thunk to nsBaseCommandController::DoCommandWithParams(char const*, nsICommandParams*) src/build/unix/stdc++compat/stdc++compat.cpp:0 #15 0x7f5f80c62c8f in nsCommandManager::DoCommand(char const*, nsICommandParams*, nsIDOMWindow*) src/embedding/components/commandhandler/src/nsCommandManager.cpp:234 #16 0x7f5f7c1e9498 in nsHTMLDocument::ExecCommand(nsAString_internal const&, bool, nsAString_internal const&, bool*) src/content/html/document/src/nsHTMLDocument.cpp:3232 #17 0x7f5f7c1eaded in non-virtual thunk to nsHTMLDocument::ExecCommand(nsAString_internal const&, bool, nsAString_internal const&, bool*) src/build/unix/stdc++compat/stdc++compat.cpp:0 #18 0x7f5f8438cef7 in NS_InvokeByIndex_P src/xpcom/reflect/xptcall/src/md/unix/xptcinvoke_x86_64_unix.cpp:162 #19 0x7f5f7f801e5e in CallMethodHelper::Invoke() src/js/xpconnect/src/XPCWrappedNative.cpp:3106 #20 0x7f5f7f8649f5 in XPC_WN_CallMethod(JSContext*, unsigned int, JS::Value*) src/js/xpconnect/src/XPCWrappedNativeJSOps.cpp:1478 #21 0x7f5f8aeeb731 in js::CallJSNative(JSContext*, int ()(JSContext, unsigned int, JS::Value*), JS::CallArgs const&) src/js/src/jscntxtinlines.h:372 #22 0x7f5f8ae78821 in js::Interpret(JSContext*, js::StackFrame*, js::InterpMode) src/js/src/jsinterp.cpp:2413 #23 0x7f5f8addf815 in js::RunScript(JSContext*, JSScript*, js::StackFrame*) src/js/src/jsinterp.cpp:309 #24 0x7f5f8aef8a46 in js::ExecuteKernel(JSContext*, JS::Handle<JSScript*>, JSObject&, JS::Value const&, js::ExecuteType, js::StackFrame*, JS::Value*) src/js/src/jsinterp.cpp:494 #25 0x7f5f8aefa9fe in js::Execute(JSContext*, JS::Handle<JSScript*>, JSObject&, JS::Value*) src/js/src/jsinterp.cpp:531 #26 0x7f5f8a652034 in JS::Evaluate(JSContext*, JS::Handle<JSObject*>, JS::CompileOptions, unsigned short const*, unsigned long, JS::Value*) src/js/src/jsapi.cpp:5665 #27 0x7f5f8a656fd1 in JS_EvaluateUCScriptForPrincipalsVersionOrigin src/js/src/jsapi.cpp:5746 #28 0x7f5f7c981e3f in nsJSContext::EvaluateString(nsAString_internal const&, JSObject*, nsIPrincipal*, nsIPrincipal*, char const*, unsigned int, JSVersion, nsAString_internal*, bool*) src/dom/base/nsJSEnvironment.cpp:1497 #29 0x7f5f7cb319cf in nsGlobalWindow::RunTimeoutHandler(nsTimeout*, nsIScriptContext*) src/dom/base/nsGlobalWindow.cpp:9590 #30 0x7f5f7cae9349 in nsGlobalWindow::RunTimeout(nsTimeout*) src/dom/base/nsGlobalWindow.cpp:9851 #31 0x7f5f7cb2fa2a in nsGlobalWindow::TimerCallback(nsITimer*, void*) src/dom/base/nsGlobalWindow.cpp:10118 #32 0x7f5f842ccbc2 in nsTimerImpl::Fire() src/xpcom/threads/nsTimerImpl.cpp:473 #33 0x7f5f842ce478 in nsTimerEvent::Run() src/xpcom/threads/nsTimerImpl.cpp:556 #34 0x7f5f84291f99 in nsThread::ProcessNextEvent(bool, bool*) src/xpcom/threads/nsThread.cpp:625 #35 0x7f5f83f34017 in NS_ProcessNextEvent_P(nsIThread*, bool) src/objdir-ff-asan-sym/xpcom/build/nsThreadUtils.cpp:220 #36 0x7f5f82d10bd5 in mozilla::ipc::MessagePump::Run(base::MessagePump::Delegate*) src/ipc/glue/MessagePump.cpp:82 #37 0x7f5f8453ea79 in MessageLoop::RunInternal() src/ipc/chromium/src/base/message_loop.cc:208 #38 0x7f5f8453e8c2 in MessageLoop::RunHandler() src/ipc/chromium/src/base/message_loop.cc:201 #39 0x7f5f8453e7a7 in MessageLoop::Run() src/ipc/chromium/src/base/message_loop.cc:175 #40 0x7f5f821dadee in nsBaseAppShell::Run() src/widget/xpwidgets/nsBaseAppShell.cpp:163 #41 0x7f5f80e4dc88 in nsAppStartup::Run() src/toolkit/components/startup/nsAppStartup.cpp:273 #42 0x7f5f776596f0 in XREMain::XRE_mainRun() src/toolkit/xre/nsAppRunner.cpp:3800 #43 0x7f5f7765f964 in XREMain::XRE_main(int, char**, nsXREAppData const*) src/toolkit/xre/nsAppRunner.cpp:3877 #44 0x7f5f77662a2e in XRE_main src/toolkit/xre/nsAppRunner.cpp:3953 #45 0x40c5bb in do_main(int, char**) src/browser/app/nsBrowserApp.cpp:174 #46 0x409e1f in main src/browser/app/nsBrowserApp.cpp:279 #47 0x7f5f9470ac4d in ?? ??:0 0x7f5f56a1dc9d is located 0 bytes to the right of 1053-byte region [0x7f5f56a1d880,0x7f5f56a1dc9d) allocated by thread T0 here: #0 0x4c3ef0 in __interceptor_malloc ??:0 #1 0x7f5f915a86c6 in moz_xmalloc src/memory/mozalloc/mozalloc.cpp:57 #2 0x7f5f843106d2 in NS_Alloc_P src/xpcom/base/nsMemoryImpl.cpp:163 #3 0x7f5f777ad7d2 in nsMemory::Alloc(unsigned long) src/../../../dist/include/nsMemory.h:36 #4 0x7f5f7acbea88 in nsTextFragment::SetTo(unsigned short const*, int, bool) src/content/base/src/nsTextFragment.cpp:264 #5 0x7f5f7aa69561 in nsGenericDOMDataNode::SetTextInternal(unsigned int, unsigned int, unsigned short const*, unsigned int, bool, CharacterDataChangeInfo::Details*) src/content/base/src/nsGenericDOMDataNode.cpp:307 #6 0x7f5f7aa776f8 in nsGenericDOMDataNode::SetText(unsigned short const*, unsigned int, bool) src/content/base/src/nsGenericDOMDataNode.cpp:850 #7 0x7f5f78bda486 in nsIContent::SetText(nsAString_internal const&, bool) src/../../../../dist/include/nsIContent.h:513 #8 0x7f5f7a487a84 in CompressWhitespace(nsIContent*) src/layout/mathml/nsMathMLTokenFrame.cpp:98 #9 0x7f5f7a4872dc in nsMathMLTokenFrame::Init(nsIContent*, nsIFrame*, nsIFrame*) src/layout/mathml/nsMathMLTokenFrame.cpp:111 #10 0x7f5f78beb992 in nsCSSFrameConstructor::InitAndRestoreFrame(nsFrameConstructorState const&, nsIContent*, nsIFrame*, nsIFrame*, nsIFrame*, bool) src/layout/base/nsCSSFrameConstructor.cpp:4545 #11 0x7f5f78c1b334 in nsCSSFrameConstructor::ConstructFrameFromItemInternal(nsCSSFrameConstructor::FrameConstructionItem&, nsFrameConstructorState&, nsIFrame*, nsFrameItems&) src/layout/base/nsCSSFrameConstructor.cpp:3647 #12 0x7f5f78c33520 in nsCSSFrameConstructor::ConstructFramesFromItem(nsFrameConstructorState&, nsCSSFrameConstructor::FrameConstructionItemList::Iterator&, nsIFrame*, nsFrameItems&) src/layout/base/nsCSSFrameConstructor.cpp:5551 #13 0x7f5f78bec989 in nsCSSFrameConstructor::ConstructFramesFromItemList(nsFrameConstructorState&, nsCSSFrameConstructor::FrameConstructionItemList&, nsIFrame*, nsFrameItems&) src/layout/base/nsCSSFrameConstructor.cpp:9817 #14 0x7f5f78beeb58 in nsCSSFrameConstructor::ProcessChildren(nsFrameConstructorState&, nsIContent*, nsStyleContext*, nsIFrame*, bool, nsFrameItems&, bool, PendingBinding*, nsIFrame*) src/layout/base/nsCSSFrameConstructor.cpp:9961 #15 0x7f5f78c04094 in nsCSSFrameConstructor::ConstructBlock(nsFrameConstructorState&, nsStyleDisplay const*, nsIContent*, nsIFrame*, nsIFrame*, nsStyleContext*, nsIFrame**, nsFrameItems&, bool, PendingBinding*) src/layout/base/nsCSSFrameConstructor.cpp:11008 #16 0x7f5f78c27c40 in nsCSSFrameConstructor::ConstructNonScrollableBlock(nsFrameConstructorState&, nsCSSFrameConstructor::FrameConstructionItem&, nsIFrame*, nsStyleDisplay const*, nsFrameItems&, nsIFrame**) src/layout/base/nsCSSFrameConstructor.cpp:4522 #17 0x7f5f78c1a74e in nsCSSFrameConstructor::ConstructFrameFromItemInternal(nsCSSFrameConstructor::FrameConstructionItem&, nsFrameConstructorState&, nsIFrame*, nsFrameItems&) src/layout/base/nsCSSFrameConstructor.cpp:3611 #18 0x7f5f78c33520 in nsCSSFrameConstructor::ConstructFramesFromItem(nsFrameConstructorState&, nsCSSFrameConstructor::FrameConstructionItemList::Iterator&, nsIFrame*, nsFrameItems&) src/layout/base/nsCSSFrameConstructor.cpp:5551 #19 0x7f5f78bec989 in nsCSSFrameConstructor::ConstructFramesFromItemList(nsFrameConstructorState&, nsCSSFrameConstructor::FrameConstructionItemList&, nsIFrame*, nsFrameItems&) src/layout/base/nsCSSFrameConstructor.cpp:9817 #20 0x7f5f78c50f02 in nsCSSFrameConstructor::ContentRangeInserted(nsIContent*, nsIContent*, nsIContent*, nsILayoutHistoryState*, bool) src/layout/base/nsCSSFrameConstructor.cpp:7218 #21 0x7f5f78c4a8fa in nsCSSFrameConstructor::ContentInserted(nsIContent*, nsIContent*, nsILayoutHistoryState*, bool) src/layout/base/nsCSSFrameConstructor.cpp:6837 #22 0x7f5f78c3af4d in nsCSSFrameConstructor::RecreateFramesForContent(nsIContent*, bool) src/layout/base/nsCSSFrameConstructor.cpp:9341 #23 0x7f5f78c6a537 in nsCSSFrameConstructor::ProcessRestyledFrames(nsStyleChangeList&) src/layout/base/nsCSSFrameConstructor.cpp:8084 #24 0x7f5f78bbb933 in mozilla::css::RestyleTracker::ProcessOneRestyle(mozilla::dom::Element*, nsRestyleHint, nsChangeHint) src/layout/base/RestyleTracker.cpp:132 Shadow byte and word: 0x1febead43b93: 5 0x1febead43b90: 00 00 00 05 fb fb fb fb More shadow bytes: 0x1febead43b70: 00 00 00 00 00 00 00 00 0x1febead43b78: 00 00 00 00 00 00 00 00 0x1febead43b80: 00 00 00 00 00 00 00 00 0x1febead43b88: 00 00 00 00 00 00 00 00 =>0x1febead43b90: 00 00 00 05 fb fb fb fb 0x1febead43b98: fb fb fb fb fb fb fb fb 0x1febead43ba0: fa fa fa fa fa fa fa fa 0x1febead43ba8: fa fa fa fa fa fa fa fa 0x1febead43bb0: fa fa fa fa fa fa fa fa Stats: 238M malloced (274M for red zones) by 500040 calls Stats: 42M realloced by 21762 calls Stats: 203M freed by 265667 calls Stats: 71M really freed by 156628 calls Stats: 448M (114766 full pages) mmaped in 112 calls mmaps by size class: 8:294894; 9:40955; 10:16380; 11:14329; 12:3072; 13:1536; 14:1280; 15:256; 16:448; 17:1248; 18:160; 19:40; 20:16; mallocs by size class: 8:406418; 9:50541; 10:17092; 11:17141; 12:2998; 13:1978; 14:1488; 15:324; 16:525; 17:1297; 18:179; 19:42; 20:17; frees by size class: 8:189390; 9:41298; 10:13781; 11:13967; 12:2077; 13:1668; 14:1286; 15:282; 16:466; 17:1284; 18:115; 19:39; 20:14; rfrees by size class: 8:117290; 9:19910; 10:7974; 11:9114; 12:582; 13:521; 14:398; 15:147; 16:339; 17:319; 18:28; 19:5; 20:1; Stats: malloc large: 1535 small slow: 2173 ==30534== ABORTING
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
What is known
A critical-severity memory corruption bug in MathML. Mozilla made it public on 31 August 2012 as CVE-2012-4180.
About Memory corruption
Native code reads or writes memory it should not: overflows, use-after-free, type confusion. The core of browser, kernel and parser bugs.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
What is Memory corruption?
Native code reads or writes memory it should not: overflows, use-after-free, type confusion. The core of browser, kernel and parser bugs.