Closed
Bug 520752
Opened 17 years ago
Closed 1 year ago
broadcasted wm_copydata message opens new window
Categories
(Core :: Widget: Win32, defect)
Tracking
()
RESOLVED
DUPLICATE
of bug 1892400
People
(Reporter: illicit, Unassigned)
References
Details
Attachments
(1 file, 1 obsolete file)
|
4.54 KB,
patch
|
robarnold
:
review+
|
Details | Diff | Splinter Review |
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-GB; rv:1.9.1.3) Gecko/20090824 Firefox/3.5.3 (.NET CLR 3.5.30729)
Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-GB; rv:1.9.1.3) Gecko/20090824 Firefox/3.5.3 (.NET CLR 3.5.30729)
After developing some applications that exchange data between them with windows messages, and especially wm_copydata, i noticed that each time i broadcasted the message, a new firefox window opens.
Reproducible: Always
Steps to Reproduce:
1. Open firefox.
2. Broadcast a windows wm_copydata message from an application
in delphi:
Sendmessage(wnd_broadcast,WM_COPYDATA,fhandle,integer(@data));
Actual Results:
A new firefox window opens
Expected Results:
Nothing. Firefox should handle the data.dwData (tagCOPYDATASTRUCT.dwData) to identify if the message recipient is firefox itself. if not it should ignore the message.
Confirming based on multiple reports
Status: UNCONFIRMED → NEW
Component: General → Widget: Win32
Ever confirmed: true
Product: Firefox → Core
QA Contact: general → win32
Updated•15 years ago
|
Assignee: nobody → netzen
Comment 3•15 years ago
|
||
It's a pretty bad idea to broadcast a message like WM_COPYDATA to all windows. In fact while testing trying to reproduce I often crashed programs including explorer by doing it.
That being said it doesn't stop programs from doing this to Firefox.
I found in the code that we use WM_COPYDATA to send a message to the already open firefox when you try to open a new one. Hence why the bug happens. So the reported problem can be reproduced by sending the right message directly and not through broadcast.
Fix pending.
Comment 4•15 years ago
|
||
The fix is basically just pre pending a magic number / signature that way we protect ourselves against broadcast messages for WM_COPYDATA.
Attachment #553190 -
Flags: review?(tellrob)
Comment 5•15 years ago
|
||
Comment on attachment 553190 [details] [diff] [review]
Fix for broadcasted WM_COPYDATA message opens new window v1
Review of attachment 553190 [details] [diff] [review]:
-----------------------------------------------------------------
r=me w/comments addressed
::: toolkit/xre/nsNativeAppSupportWin.cpp
@@ +83,5 @@
> #include <direct.h>
> #include <fcntl.h>
>
> static HWND hwndForDOMWindow( nsISupports * );
> +static char WM_COPYDATA_Signature[] = "{F3C9DD09-4994-4c8c-B1D9-A2FD8CEF04F9}";
nit: inconsistent capitalization in the guid string
@@ +597,5 @@
> // This is an incoming request.
> COPYDATASTRUCT *cds = (COPYDATASTRUCT*)lp;
> +
> + char *pData = (char *)cds->lpData;
> + // WM_COPYDATA requests should be preceded by [WM_COPYDATA_Signature]\0
I'd like a little bit more of a comment here. In particular, describe why we might get a WM_COPYDATA which doesn't have the GUID.
@@ +602,5 @@
> + if (cds->cbData <= NS_ARRAY_LENGTH(WM_COPYDATA_Signature)) {
> + return FALSE;
> + }
> + else {
> + if(strncmp(WM_COPYDATA_Signature, (const char*)cds->lpData,
s/(const char*)cds->lpData/pData
@@ +603,5 @@
> + return FALSE;
> + }
> + else {
> + if(strncmp(WM_COPYDATA_Signature, (const char*)cds->lpData,
> + NS_ARRAY_LENGTH(WM_COPYDATA_Signature)-1)) {
I think you don't really need the -1 since there's a \0 terminator but I think this shouldn't affect correctness
Comment 6•15 years ago
|
||
The -1 I guess would mean that it doesn't need to do an extra \0 check step. But it would also mean that you could have a non \0 character instead of the \0 as that character. So it's not a big diff but I'll do as you suggested with removing the -1.
Comment 7•15 years ago
|
||
> Strangely enough GUIDGen.exe will not capitalize letters in that position.
Comment 8•15 years ago
|
||
Implemented all review comments.
Attachment #553190 -
Attachment is obsolete: true
Attachment #553253 -
Flags: review?(tellrob)
Attachment #553190 -
Flags: review?(tellrob)
Updated•15 years ago
|
Attachment #553253 -
Flags: review?(tellrob) → review+
Comment 9•14 years ago
|
||
This has an r+ but I'm holding off on landing it until I can do more testing. In particular I'm concerned it could have problems when multiple browsers of different versions are installed on the same machine.
Updated•13 years ago
|
Assignee: netzen → nobody
Updated•4 years ago
|
Severity: normal → S3
Comment 10•1 year ago
|
||
The modern version of this in WinRemoteMessageReceiver now has a magic sequence that it checks for and ignores the message if it does not. Closing.
You need to log in
before you can comment on or make changes to this bug.
Description
•