shell32: check cbSize in Shell_NotifyIconW to make apps sending garbage work (fixes bug #7940)

Mikołaj Zalewski mikolaj at zalewski.pl
Sat May 5 13:15:51 CDT 2007


Shareaza requires this.
-------------- next part --------------
From f5799d443dd31e7ffe695f2d62842e1ef0e06c30 Mon Sep 17 00:00:00 2001
From: =?utf-8?q?Miko=C5=82aj_Zalewski?= <mikolaj at zalewski.pl>
Date: Sat, 5 May 2007 13:45:43 +0200
Subject: [PATCH] shell32: check cbSize in Shell_NotifyIconW to make apps sending garbage work (fixes bug #7940)

---
 dlls/shell32/systray.c |   12 ++++++++++++
 1 files changed, 12 insertions(+), 0 deletions(-)

diff --git a/dlls/shell32/systray.c b/dlls/shell32/systray.c
index 824eeb9..8b92fe9 100644
--- a/dlls/shell32/systray.c
+++ b/dlls/shell32/systray.c
@@ -92,6 +92,18 @@ BOOL WINAPI Shell_NotifyIconW(DWORD dwMessage, PNOTIFYICONDATAW nid)
     char *buffer = NULL;
 
     TRACE("dwMessage = %d, nid->cbSize=%d\n", dwMessage, nid->cbSize);
+    
+    /* The validation is also done in explorer. However we must also do it
+     * on the client size so that WM_COPYDATA doesn't crash the application
+     */
+    if (nid->cbSize != NOTIFYICONDATAW_V1_SIZE &&
+        nid->cbSize != NOTIFYICONDATAW_V2_SIZE &&
+        nid->cbSize != NOTIFYICONDATAW_V3_SIZE &&
+        nid->cbSize != sizeof(NOTIFYICONDATAW))
+    {
+        WARN("Invalid size\n");
+        return FALSE;
+    }
 
     tray = FindWindowExW(0, NULL, classname, NULL);
     if (!tray) return FALSE;
-- 
1.4.4.2


More information about the wine-patches mailing list