Closed
Bug 934939
Opened 13 years ago
Closed 12 years ago
Heap-buffer-overflow in nsPNGEncoder::ConvertHostARGBRow
Categories
(Core :: Graphics: Canvas2D, defect)
Tracking
()
RESOLVED
FIXED
mozilla28
| Tracking | Status | |
|---|---|---|
| firefox26 | --- | unaffected |
| firefox27 | --- | unaffected |
| firefox28 | --- | fixed |
| firefox-esr24 | --- | unaffected |
| b2g18 | --- | unaffected |
People
(Reporter: attekett, Assigned: spohl)
References
Details
(5 keywords, Whiteboard: [qa-])
Attachments
(2 files, 2 obsolete files)
|
1.06 KB,
patch
|
roc
:
review+
|
Details | Diff | Splinter Review |
|
1011 bytes,
patch
|
spohl
:
review+
|
Details | Diff | Splinter Review |
Tested on:
OS: Ubuntu 12.04
Firefox: ASAN opt-build from https://ftp.mozilla.org/pub/mozilla.org/firefox/tinderbox-builds/mozilla-central-linux64-asan-debug/1383633938/
Repro-file:
<script type="text/javascript">
function run() {
var cx = canvas.getContext("2d");
canvas.toDataURL("image/png")
}
</script>
<body onload="run()">
<canvas width="1" height="65536" id="canvas"></canvas>
With fast look I found out that the value of the canvas-element height attribute affects the crash. When set into any value between 33000-65536 FF will crash. When set into any value below 32000 crashing stops. I didn't dig into values above 65536 and into the specific value between 32000 and 33000.
ASAN-report:
==8970==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x6020002a5574 at pc 0x7f09e1192d11 bp 0x7fff737f5460 sp 0x7fff737f5458
READ of size 4 at 0x6020002a5574 thread T0
#0 0x7f09e1192d10 in nsPNGEncoder::ConvertHostARGBRow(unsigned char const*, unsigned char*, unsigned int, bool) /builds/slave/m-cen-l64-asan-000000000000000/build/image/encoders/png/nsPNGEncoder.cpp:599:0
#1 0x7f09e1191898 in nsPNGEncoder::AddImageFrame(unsigned char const*, unsigned int, unsigned int, unsigned int, unsigned int, unsigned int, nsAString_internal const&) /builds/slave/m-cen-l64-asan-000000000000000/build/image/encoders/png/nsPNGEncoder.cpp:267:0
#2 0x7f09e1190999 in nsPNGEncoder::InitFromData(unsigned char const*, unsigned int, unsigned int, unsigned int, unsigned int, unsigned int, nsAString_internal const&) /builds/slave/m-cen-l64-asan-000000000000000/build/image/encoders/png/nsPNGEncoder.cpp:62:0
#3 0x7f09e1d904c4 in mozilla::dom::ImageEncoder::GetInputStream(int, int, unsigned char*, int, imgIEncoder*, char16_t const*, nsIInputStream**) /builds/slave/m-cen-l64-asan-000000000000000/build/content/canvas/src/ImageEncoder.cpp:242:0
#4 0x7f09e1d62717 in mozilla::dom::CanvasRenderingContext2D::GetInputStream(char const*, char16_t const*, nsIInputStream**) /builds/slave/m-cen-l64-asan-000000000000000/build/content/canvas/src/CanvasRenderingContext2D.cpp:1102:0
#5 0x7f09e1d8fb51 in mozilla::dom::ImageEncoder::ExtractDataInternal(nsAString_internal const&, nsAString_internal const&, unsigned char*, int, nsIntSize, nsICanvasRenderingContextInternal*, nsIInputStream**, imgIEncoder*) /builds/slave/m-cen-l64-asan-000000000000000/build/content/canvas/src/ImageEncoder.cpp:279:0
#6 0x7f09e1d8ed40 in mozilla::dom::ImageEncoder::ExtractData(nsAString_internal&, nsAString_internal const&, nsIntSize, nsICanvasRenderingContextInternal*, nsIInputStream**) /builds/slave/m-cen-l64-asan-000000000000000/build/content/canvas/src/ImageEncoder.cpp:194:0
#7 0x7f09e1f12e4a in operator class nsIInputStream ** /builds/slave/m-cen-l64-asan-000000000000000/build/content/html/content/src/HTMLCanvasElement.cpp:393:0
#8 0x7f09e1f12e4a in mozilla::dom::HTMLCanvasElement::ToDataURLImpl(JSContext*, nsAString_internal const&, JS::Value const&, nsAString_internal&) /builds/slave/m-cen-l64-asan-000000000000000/build/content/html/content/src/HTMLCanvasElement.cpp:465:0
#9 0x7f09e44fedc7 in operator class nsString & /builds/slave/m-cen-l64-asan-000000000000000/build/obj-firefox/dom/bindings/../../dist/include/mozilla/dom/HTMLCanvasElement.h:92:0
#10 0x7f09e44fedc7 in mozilla::dom::HTMLCanvasElementBinding::toDataURL(JSContext*, JS::Handle<JSObject*>, mozilla::dom::HTMLCanvasElement*, JSJitMethodCallArgs const&) /builds/slave/m-cen-l64-asan-000000000000000/build/obj-firefox/dom/bindings/./HTMLCanvasElementBinding.cpp:251:0
#11 0x7f09e44fd0ea in mozilla::dom::HTMLCanvasElementBinding::genericMethod(JSContext*, unsigned int, JS::Value*) /builds/slave/m-cen-l64-asan-000000000000000/build/obj-firefox/dom/bindings/./HTMLCanvasElementBinding.cpp:605:0
#12 0x7f09e6c1c8c7 in native /builds/slave/m-cen-l64-asan-000000000000000/build/js/src/jscntxtinlines.h:220:0
#13 0x7f09e6c1c8c7 in js::Invoke(JSContext*, JS::CallArgs, js::MaybeConstruct) /builds/slave/m-cen-l64-asan-000000000000000/build/js/src/vm/Interpreter.cpp:463:0
#14 0x7f09e6c1180b in Interpret(JSContext*, js::RunState&) /builds/slave/m-cen-l64-asan-000000000000000/build/js/src/vm/Interpreter.cpp:2502:0
#15 0x7f09e6bf8a93 in js::RunScript(JSContext*, js::RunState&) /builds/slave/m-cen-l64-asan-000000000000000/build/js/src/vm/Interpreter.cpp:420:0
#16 0x7f09e6c1cb03 in js::Invoke(JSContext*, JS::CallArgs, js::MaybeConstruct) /builds/slave/m-cen-l64-asan-000000000000000/build/js/src/vm/Interpreter.cpp:482:0
#17 0x7f09e6c1d878 in js::Invoke(JSContext*, JS::Value const&, JS::Value const&, unsigned int, JS::Value*, JS::MutableHandle<JS::Value>) /builds/slave/m-cen-l64-asan-000000000000000/build/js/src/vm/Interpreter.cpp:513:0
#18 0x7f09e69228f7 in JS_CallFunctionValue(JSContext*, JSObject*, JS::Value, unsigned int, JS::Value*, JS::Value*) /builds/slave/m-cen-l64-asan-000000000000000/build/js/src/jsapi.cpp:4906:0
#19 0x7f09e43b35cf in mozilla::dom::EventHandlerNonNull::Call(JSContext*, JS::Handle<JSObject*>, nsDOMEvent&, mozilla::ErrorResult&) /builds/slave/m-cen-l64-asan-000000000000000/build/obj-firefox/dom/bindings/./EventHandlerBinding.cpp:37:0
#20 0x7f09e26adf23 in Call<nsISupports *> /builds/slave/m-cen-l64-asan-000000000000000/build/obj-firefox/dom/src/events/../../../dist/include/mozilla/dom/EventHandlerBinding.h:59:0
#21 0x7f09e26adf23 in nsJSEventListener::HandleEvent(nsIDOMEvent*) /builds/slave/m-cen-l64-asan-000000000000000/build/dom/src/events/nsJSEventListener.cpp:245:0
#22 0x7f09e1e97d72 in nsEventListenerManager::HandleEventSubType(nsListenerStruct*, mozilla::dom::CallbackObjectHolder<mozilla::dom::EventListener, nsIDOMEventListener> const&, nsIDOMEvent*, mozilla::dom::EventTarget*, nsCxPusher*) /builds/slave/m-cen-l64-asan-000000000000000/build/content/events/src/nsEventListenerManager.cpp:955:0
#23 0x7f09e1e98b4f in nsEventListenerManager::HandleEventInternal(nsPresContext*, mozilla::WidgetEvent*, nsIDOMEvent**, mozilla::dom::EventTarget*, nsEventStatus*, nsCxPusher*) /builds/slave/m-cen-l64-asan-000000000000000/build/content/events/src/nsEventListenerManager.cpp:1029:0
#24 0x7f09e1e89a83 in CurrentTarget /builds/slave/m-cen-l64-asan-000000000000000/build/content/events/src/nsEventListenerManager.h:325:0
#25 0x7f09e1e89a83 in nsEventTargetChainItem::HandleEvent(nsEventChainPostVisitor&, ELMCreationDetector&, nsCxPusher*) /builds/slave/m-cen-l64-asan-000000000000000/build/content/events/src/nsEventDispatcher.cpp:195:0
#26 0x7f09e1e8895e in nsEventTargetChainItem::HandleEventTargetChain(nsTArray<nsEventTargetChainItem>&, nsEventChainPostVisitor&, nsDispatchingCallback*, ELMCreationDetector&, nsCxPusher*) /builds/slave/m-cen-l64-asan-000000000000000/build/content/events/src/nsEventDispatcher.cpp:292:0
#27 0x7f09e1e8c9f4 in nsEventDispatcher::Dispatch(nsISupports*, nsPresContext*, mozilla::WidgetEvent*, nsIDOMEvent*, nsEventStatus*, nsDispatchingCallback*, nsCOMArray<mozilla::dom::EventTarget>*) /builds/slave/m-cen-l64-asan-000000000000000/build/content/events/src/nsEventDispatcher.cpp:605:0
#28 0x7f09e131ce7b in nsDocumentViewer::LoadComplete(tag_nsresult) /builds/slave/m-cen-l64-asan-000000000000000/build/layout/base/nsDocumentViewer.cpp:994:0
#29 0x7f09e5436dba in nsDocShell::EndPageLoad(nsIWebProgress*, nsIChannel*, tag_nsresult) /builds/slave/m-cen-l64-asan-000000000000000/build/docshell/base/nsDocShell.cpp:6776:0
#30 0x7f09e5434049 in nsDocShell::OnStateChange(nsIWebProgress*, nsIRequest*, unsigned int, tag_nsresult) /builds/slave/m-cen-l64-asan-000000000000000/build/docshell/base/nsDocShell.cpp:6573:0
#31 0x7f09e543458c in non-virtual thunk to nsDocShell::OnStateChange(nsIWebProgress*, nsIRequest*, unsigned int, tag_nsresult) /builds/slave/m-cen-l64-asan-000000000000000/build/docshell/base/nsDocShell.cpp:6579:0
#32 0x7f09e548749f in nsDocLoader::DoFireOnStateChange(nsIWebProgress*, nsIRequest*, int&, tag_nsresult) /builds/slave/m-cen-l64-asan-000000000000000/build/uriloader/base/nsDocLoader.cpp:1331:0
#33 0x7f09e54867f3 in nsDocLoader::doStopDocumentLoad(nsIRequest*, tag_nsresult) /builds/slave/m-cen-l64-asan-000000000000000/build/uriloader/base/nsDocLoader.cpp:865:0
#34 0x7f09e548448f in nsDocLoader::DocLoaderIsEmpty(bool) /builds/slave/m-cen-l64-asan-000000000000000/build/uriloader/base/nsDocLoader.cpp:755:0
#35 0x7f09e5485a08 in nsDocLoader::OnStopRequest(nsIRequest*, nsISupports*, tag_nsresult) /builds/slave/m-cen-l64-asan-000000000000000/build/uriloader/base/nsDocLoader.cpp:639:0
#36 0x7f09e54862a9 in non-virtual thunk to nsDocLoader::OnStopRequest(nsIRequest*, nsISupports*, tag_nsresult) /builds/slave/m-cen-l64-asan-000000000000000/build/uriloader/base/nsDocLoader.cpp:642:0
#37 0x7f09e0a7ea59 in nsLoadGroup::RemoveRequest(nsIRequest*, nsISupports*, tag_nsresult) /builds/slave/m-cen-l64-asan-000000000000000/build/netwerk/base/src/nsLoadGroup.cpp:688:0
#38 0x7f09e1b745e6 in nsDocument::DoUnblockOnload() /builds/slave/m-cen-l64-asan-000000000000000/build/content/base/src/nsDocument.cpp:7988:0
#39 0x7f09e1b7429b in nsDocument::UnblockOnload(bool) /builds/slave/m-cen-l64-asan-000000000000000/build/content/base/src/nsDocument.cpp:7916:0
#40 0x7f09e1b52f62 in nsDocument::DispatchContentLoadedEvents() /builds/slave/m-cen-l64-asan-000000000000000/build/content/base/src/nsDocument.cpp:4702:0
#41 0x7f09e1b9767c in nsRunnableMethodImpl<void (nsDocument::*)(), void, true>::Run() /builds/slave/m-cen-l64-asan-000000000000000/build/obj-firefox/content/base/src/../../../dist/include/nsThreadUtils.h:382:0
#42 0x7f09e4f759f9 in nsThread::ProcessNextEvent(bool, bool*) /builds/slave/m-cen-l64-asan-000000000000000/build/xpcom/threads/nsThread.cpp:622:0
#43 0x7f09e4ea4ac1 in NS_ProcessNextEvent(nsIThread*, bool) /builds/slave/m-cen-l64-asan-000000000000000/build/xpcom/glue/nsThreadUtils.cpp:251:0
#44 0x7f09e321628c in nsXULWindow::ShowModal() /builds/slave/m-cen-l64-asan-000000000000000/build/xpfe/appshell/src/nsXULWindow.cpp:365:0
#45 0x7f09e315932a in nsWindowWatcher::OpenWindowInternal(nsIDOMWindow*, char const*, char const*, char const*, bool, bool, bool, nsIArray*, nsIDOMWindow**) /builds/slave/m-cen-l64-asan-000000000000000/build/embedding/components/windowwatcher/src/nsWindowWatcher.cpp:970:0
#46 0x7f09e3155198 in nsWindowWatcher::OpenWindow(nsIDOMWindow*, char const*, char const*, char const*, nsISupports*, nsIDOMWindow**) /builds/slave/m-cen-l64-asan-000000000000000/build/embedding/components/windowwatcher/src/nsWindowWatcher.cpp:344:0
#47 0x7f09e4fb8a01 in NS_InvokeByIndex /builds/slave/m-cen-l64-asan-000000000000000/build/xpcom/reflect/xptcall/src/md/unix/xptcinvoke_x86_64_unix.cpp:162:0
#48 0x7f09e30bc8d6 in Invoke /builds/slave/m-cen-l64-asan-000000000000000/build/js/xpconnect/src/XPCWrappedNative.cpp:2797:0
#49 0x7f09e30bc8d6 in CallMethodHelper /builds/slave/m-cen-l64-asan-000000000000000/build/js/xpconnect/src/XPCWrappedNative.cpp:2137:0
#50 0x7f09e30bc8d6 in XPCWrappedNative::CallMethod(XPCCallContext&, XPCWrappedNative::CallMode) /builds/slave/m-cen-l64-asan-000000000000000/build/js/xpconnect/src/XPCWrappedNative.cpp:2103:0
#51 0x7f09e30cdabb in XPC_WN_CallMethod(JSContext*, unsigned int, JS::Value*) /builds/slave/m-cen-l64-asan-000000000000000/build/js/xpconnect/src/XPCWrappedNativeJSOps.cpp:1311:0
#52 0x7f09e6c1c8c7 in native /builds/slave/m-cen-l64-asan-000000000000000/build/js/src/jscntxtinlines.h:220:0
#53 0x7f09e6c1c8c7 in js::Invoke(JSContext*, JS::CallArgs, js::MaybeConstruct) /builds/slave/m-cen-l64-asan-000000000000000/build/js/src/vm/Interpreter.cpp:463:0
#54 0x7f09e6c1180b in Interpret(JSContext*, js::RunState&) /builds/slave/m-cen-l64-asan-000000000000000/build/js/src/vm/Interpreter.cpp:2502:0
#55 0x7f09e6bf8a93 in js::RunScript(JSContext*, js::RunState&) /builds/slave/m-cen-l64-asan-000000000000000/build/js/src/vm/Interpreter.cpp:420:0
#56 0x7f09e6c1cb03 in js::Invoke(JSContext*, JS::CallArgs, js::MaybeConstruct) /builds/slave/m-cen-l64-asan-000000000000000/build/js/src/vm/Interpreter.cpp:482:0
#57 0x7f09e6c1d878 in js::Invoke(JSContext*, JS::Value const&, JS::Value const&, unsigned int, JS::Value*, JS::MutableHandle<JS::Value>) /builds/slave/m-cen-l64-asan-000000000000000/build/js/src/vm/Interpreter.cpp:513:0
#58 0x7f09e69228f7 in JS_CallFunctionValue(JSContext*, JSObject*, JS::Value, unsigned int, JS::Value*, JS::Value*) /builds/slave/m-cen-l64-asan-000000000000000/build/js/src/jsapi.cpp:4906:0
#59 0x7f09e30a9948 in nsXPCWrappedJSClass::CallMethod(nsXPCWrappedJS*, unsigned short, XPTMethodDescriptor const*, nsXPTCMiniVariant*) /builds/slave/m-cen-l64-asan-000000000000000/build/js/xpconnect/src/XPCWrappedJSClass.cpp:1423:0
#60 0x7f09e309d330 in nsXPCWrappedJS::CallMethod(unsigned short, XPTMethodDescriptor const*, nsXPTCMiniVariant*) /builds/slave/m-cen-l64-asan-000000000000000/build/js/xpconnect/src/XPCWrappedJS.cpp:591:0
#61 0x7f09e4fb9bea in PrepareAndDispatch /builds/slave/m-cen-l64-asan-000000000000000/build/xpcom/reflect/xptcall/src/md/unix/xptcstubs_x86_64_linux.cpp:122:0
#62 0x7f09e4fb8c36 in SharedStub /builds/slave/m-cen-l64-asan-000000000000000/build/xpcom/reflect/xptcall/src/md/unix/xptcstubs_x86_64_linux.cpp:0
0x6020002a5574 is located 0 bytes to the right of 4-byte region [0x6020002a5570,0x6020002a5574)
allocated by thread T0 here:
#0 0x446395 in malloc _asan_rtl_:0
#1 0x7f09e1d61cef in operator new[] /builds/slave/m-cen-l64-asan-000000000000000/build/obj-firefox/content/canvas/src/../../../dist/include/mozilla/mozalloc.h:219:0
#2 0x7f09e1d61cef in mozilla::gfx::SurfaceToPackedBGRA(mozilla::gfx::SourceSurface*) /builds/slave/m-cen-l64-asan-000000000000000/build/obj-firefox/content/canvas/src/../../../dist/include/mozilla/gfx/DataSurfaceHelpers.h:49:0
#3 0x7f09e1d619a1 in mozilla::dom::CanvasRenderingContext2D::GetImageBuffer(unsigned char**, int*) /builds/slave/m-cen-l64-asan-000000000000000/build/content/canvas/src/CanvasRenderingContext2D.cpp:1078:0
#4 0x7f09e1d62449 in mozilla::dom::CanvasRenderingContext2D::GetInputStream(char const*, char16_t const*, nsIInputStream**) /builds/slave/m-cen-l64-asan-000000000000000/build/content/canvas/src/CanvasRenderingContext2D.cpp:1089:0
#5 0x7f09e1d8fb51 in mozilla::dom::ImageEncoder::ExtractDataInternal(nsAString_internal const&, nsAString_internal const&, unsigned char*, int, nsIntSize, nsICanvasRenderingContextInternal*, nsIInputStream**, imgIEncoder*) /builds/slave/m-cen-l64-asan-000000000000000/build/content/canvas/src/ImageEncoder.cpp:279:0
#6 0x7f09e1d8ed40 in mozilla::dom::ImageEncoder::ExtractData(nsAString_internal&, nsAString_internal const&, nsIntSize, nsICanvasRenderingContextInternal*, nsIInputStream**) /builds/slave/m-cen-l64-asan-000000000000000/build/content/canvas/src/ImageEncoder.cpp:194:0
Shadow bytes around the buggy address:
0x0c048004ca50: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
0x0c048004ca60: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
0x0c048004ca70: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
0x0c048004ca80: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
0x0c048004ca90: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
=>0x0c048004caa0: fa fa fa fa fa fa 05 fa fa fa 04 fa fa fa[04]fa
0x0c048004cab0: fa fa fd fa fa fa 00 fa fa fa 00 00 fa fa 00 00
0x0c048004cac0: fa fa 00 06 fa fa 00 fa fa fa fd fd fa fa fd fa
0x0c048004cad0: fa fa 00 00 fa fa fd fa fa fa 00 00 fa fa fd fd
0x0c048004cae0: fa fa fd fa fa fa 00 00 fa fa fd fd fa fa 00 fa
0x0c048004caf0: fa fa fd fd fa fa fd fd fa fa 00 00 fa fa 00 fa
Shadow byte legend (one shadow byte represents 8 application bytes):
Addressable: 00
Partially addressable: 01 02 03 04 05 06 07
Heap left redzone: fa
Heap right redzone: fb
Freed heap region: fd
Stack left redzone: f1
Stack mid redzone: f2
Stack right redzone: f3
Stack partial redzone: f4
Stack after return: f5
Stack use after scope: f8
Global redzone: f9
Global init order: f6
Poisoned by user: f7
ASan internal: fe
==8970==ABORTING
It looks like the problem isn't in the png conversion because with 'canvas.toDataURL("image/png")' changed into 'canvas.toDataURL("image/bmp")' the crash changes into a
==9608==ERROR: AddressSanitizer: SEGV on unknown address 0x6020002c74ee (pc 0x7f390d58a3da sp 0x7ffffc26eb60 bp 0x000000008ca0 T0)
AddressSanitizer can not provide additional info.
#0 0x7f390d58a3d9 in nsBMPEncoder::ConvertHostARGBRow(unsigned char const*, unsigned char*, unsigned int) /builds/slave/m-cen-l64-asan-000000000000000/build/image/encoders/bmp/nsBMPEncoder.cpp:435:0
#1 0x7f390d58801a in nsBMPEncoder::AddImageFrame(unsigned char const*, unsigned int, unsigned int, unsigned int, unsigned int, unsigned int, nsAString_internal const&) /builds/slave/m-cen-l64-asan-000000000000000/build/image/encoders/bmp/nsBMPEncoder.cpp:196:0
#2 0x7f390d5871a6 in nsBMPEncoder::InitFromData(unsigned char const*, unsigned int, unsigned int, unsigned int, unsigned int, unsigned int, nsAString_internal const&) /builds/slave/m-cen-l64-asan-000000000000000/build/image/encoders/bmp/nsBMPEncoder.cpp:73:0
#3 0x7f390e1804c4 in mozilla::dom::ImageEncoder::GetInputStream(int, int, unsigned char*, int, imgIEncoder*, char16_t const*, nsIInputStream**) /builds/slave/m-cen-l64-asan-000000000000000/build/content/canvas/src/ImageEncoder.cpp:242:0
#4 0x7f390e152717 in mozilla::dom::CanvasRenderingContext2D::GetInputStream(char const*, char16_t const*, nsIInputStream**) /builds/slave/m-cen-l64-asan-000000000000000/build/content/canvas/src/CanvasRenderingContext2D.cpp:1102:0
#5 0x7f390e17fb51 in mozilla::dom::ImageEncoder::ExtractDataInternal(nsAString_internal const&, nsAString_internal const&, unsigned char*, int, nsIntSize, nsICanvasRenderingContextInternal*, nsIInputStream**, imgIEncoder*) /builds/slave/m-cen-l64-asan-000000000000000/build/content/canvas/src/ImageEncoder.cpp:279:0
.
.
.
Updated•13 years ago
|
Updated•13 years ago
|
Keywords: csec-bounds
Comment 1•13 years ago
|
||
I can reproduce the heap-buffer-overflow in nsPNGEncoder::ConvertHostARGBRow using ASan on Mac.
In a Mac debug build, I get an assertion failure instead:
Assertion failure: data->GetSize() == IntSize(mWidth, mHeight), at ../../../../content/canvas/src/CanvasRenderingContext2D.cpp:1075
Updated•13 years ago
|
Keywords: csec-bounds
Comment 2•13 years ago
|
||
The PNG encoder hasn't been touched in AGES, so odd coincidence that Atte and Nils find what looks like the same bug within two days of each other. Did we change something elsewhere like Canvas? Was there a recent update of the ASan tool? Or was it really just a coincidence?
Updated•12 years ago
|
Flags: needinfo?(milan)
Updated•12 years ago
|
Keywords: regressionwindow-wanted
Comment 3•12 years ago
|
||
There were some recent changes to canvas, but that probably just tickled this, rather than caused it.
Flags: needinfo?(milan)
Comment 6•12 years ago
|
||
spohl, could this be a regression from bug 817700?
| Assignee | ||
Comment 7•12 years ago
|
||
I can't see an immediate link with bug 817700, but the value appears to become problematic once it exceeds the max value for a signed 16-bit integer (32768 or 0x8000). This number seems awfully familiar from tests I did a while back. Will try to remember the details.
| Assignee | ||
Comment 8•12 years ago
|
||
Okay, I was thinking of the checks that we perform in gfxASurface::CheckSurfaceSize. We may be missing a check somewhere. I also found this recent change [2] which is responsible for the assert in comment 1.
[1] http://mxr.mozilla.org/mozilla-central/source/gfx/thebes/gfxASurface.cpp#390
[2] http://hg.mozilla.org/mozilla-central/rev/8b66c7ae1aa6
| Assignee | ||
Comment 9•12 years ago
|
||
The specified canvas size (height: 65536) is clearly not supported, although I don't know all the specifics behind it. Some limitations seem to be explained in gfxASurface::CheckSurfaceSize [1]. I think what we need to do here is recognize when this situation occurs and bail gracefully. Since the (potentially unsupported) canvas size can be specified by content, it isn't sufficient to assert in debug builds. At the point of failure, data->GetSize() is equal to [1, 1]. This size is the default for a canvas with size [0, 0] (see bug 924573), which leads me to believe that the surface size can also be set to [1, 1] when it is invalid. This patch returns a null image buffer when we encounter an invalid surface size, which is translated to NS_ERROR_FAILURE in CanvasRenderingContext2D::GetInputStream.
[1] http://mxr.mozilla.org/mozilla-central/source/gfx/thebes/gfxASurface.cpp#390
Assignee: nobody → spohl.mozilla.bugs
Status: NEW → ASSIGNED
Attachment #8335552 -
Flags: review?(roc)
| Assignee | ||
Comment 11•12 years ago
|
||
Attachment #8335552 -
Flags: review?(roc) → review+
Comment on attachment 8335553 [details] [diff] [review]
Test
Review of attachment 8335553 [details] [diff] [review]:
-----------------------------------------------------------------
::: content/canvas/crashtests/934939-1.html
@@ +1,4 @@
> +<script type="text/javascript">
> + function run() {
> + var cx = canvas.getContext("2d");
> + canvas.toDataURL("image/png")
Lose trailing whitespace and fix indent
Attachment #8335553 -
Flags: review?(roc) → review+
| Assignee | ||
Comment 13•12 years ago
|
||
Thanks, Rob! Addressed feedback and dropped unused cx variable. Carrying over r+.
Attachment #8335553 -
Attachment is obsolete: true
Attachment #8335607 -
Flags: review+
| Assignee | ||
Comment 14•12 years ago
|
||
Hmm, cx is unused but necessary to cause the crash, so back it is. Carrying over r+.
Attachment #8335607 -
Attachment is obsolete: true
Attachment #8335610 -
Flags: review+
| Assignee | ||
Comment 15•12 years ago
|
||
Comment 16•12 years ago
|
||
What branches does this affect? Is this a regression from anything?
| Assignee | ||
Comment 17•12 years ago
|
||
(In reply to Andrew McCreight [:mccr8] from comment #16)
> What branches does this affect?
I believe this is nightly only.
> Is this a regression from anything?
I've confirmed that the assertion on Mac debug (reported in comment 1) was caused by bug 933030. The patches landed in the following range, and the assertion started occurring in nightly 2013-11-05:
http://hg.mozilla.org/mozilla-central/pushloghtml?startdate=2013-11-04&enddate=2013-11-05
If someone could confirm that the heap-buffer-overflow in ASan builds is indeed fixed, I'd appreciate it. I'd figure out how to do this myself, but I'm out for most of tomorrow. Thanks!
Updated•12 years ago
|
status-b2g18:
--- → unaffected
status-firefox26:
--- → unaffected
status-firefox27:
--- → unaffected
status-firefox28:
--- → affected
status-firefox-esr24:
--- → unaffected
Comment 18•12 years ago
|
||
landed on central
https://hg.mozilla.org/mozilla-central/rev/99168f3ce94c
https://hg.mozilla.org/mozilla-central/rev/5e0298792335
Status: ASSIGNED → RESOLVED
Closed: 12 years ago
Flags: in-testsuite+
Resolution: --- → FIXED
Target Milestone: --- → mozilla28
Comment 20•12 years ago
|
||
If this needs extra QA testing please remove the [qa-] whiteboard tag and add the verifyme keyword.
Whiteboard: [qa-]
Comment 21•12 years ago
|
||
There are still crashes occurring at that same point in the PNG encoder (see bug #984358). There is a potential overwrite of the first byte after the final byte in the image, with zero. I'm testing a fix for that now.
Updated•12 years ago
|
Flags: sec-bounty?
| Assignee | ||
Comment 22•12 years ago
|
||
(In reply to Glenn Randers-Pehrson from comment #21)
> There are still crashes occurring at that same point in the PNG encoder (see
> bug #984358). There is a potential overwrite of the first byte after the
> final byte in the image, with zero. I'm testing a fix for that now.
Thanks for the heads up. Although the top frames of the call stacks are identical, they are different from frame 3 downwards. The patch in this bug is to fix the issue reported here (and for which a dedicated test exists). We should treat these as separate issues.
Comment 23•12 years ago
|
||
OK. I tried reverting this patch, but on Ubuntu-14.04LTS I don't get a crash
with the crash test 934939-1.html. What attracted me here is that this
patch probably caused bug #967656.
| Assignee | ||
Comment 24•12 years ago
|
||
(In reply to Glenn Randers-Pehrson from comment #23)
> What attracted me here is that this patch probably caused bug #967656.
I'm hoping that the patch here didn't cause bug 967656, but hopefully just prevent it from crashing. The size limitation was pre-existing (see comment 9 and comment 7). The difference should be that we now abort further processing when we hit an unsupported size, rather than continue and crash (debug builds used to assert).
Comment 25•12 years ago
|
||
Before this bug was fixed, larger than 32k dimensions were supported if the image format would support it (i.e., not JPEG or GIF, but supported by BMP and PNG).
| Assignee | ||
Comment 26•12 years ago
|
||
Seth, could you have a quick look at comment 25? This may have worked before the patch here, but I'm not sure this was ever safe. Please feel free to forward the n-i request if I should be asking someone else.
Flags: needinfo?(seth)
Comment 27•12 years ago
|
||
The inability to to view images wider than 32k happened between Firefox 27.0b1 and 27.0b2, which I believe is when this patch landed.
Comment 28•12 years ago
|
||
Glenn: please file a separate bug for any regressions from this bug that you found, and mark them blocking this one.
| Assignee | ||
Comment 29•12 years ago
|
||
Per bug 967656 comment 17, there seems to have been a misunderstanding about the impact of the patch here. Clearing n-i request.
Flags: needinfo?(seth)
Updated•12 years ago
|
Flags: sec-bounty? → sec-bounty+
Updated•11 years ago
|
Group: core-security
Updated•11 years ago
|
Keywords: regressionwindow-wanted
Updated•9 years ago
|
Keywords: csectype-bounds
Updated•2 years ago
|
Keywords: reporter-external
You need to log in
before you can comment on or make changes to this bug.
Description
•