[PATCH] user32: Fix NULL dereference in UnregisterDeviceNotification
Arkadiusz Hiler
arek at hiler.eu
Sat May 23 15:53:36 CDT 2020
UnregisterDeviceNotification when provided with NULL should not try to
dereference it and just return FALSE.
This fixes crashes in BandLab Cakewalk and Glorious Model O control software.
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=49211
Signed-off-by: Arkadiusz Hiler <arek at hiler.eu>
---
dlls/sechost/service.c | 3 +++
dlls/user32/tests/Makefile.in | 1 +
dlls/user32/tests/misc.c | 33 +++++++++++++++++++++++++++++++++
3 files changed, 37 insertions(+)
create mode 100644 dlls/user32/tests/misc.c
diff --git a/dlls/sechost/service.c b/dlls/sechost/service.c
index 924a6c9264..68d2b9e78e 100644
--- a/dlls/sechost/service.c
+++ b/dlls/sechost/service.c
@@ -2109,6 +2109,9 @@ BOOL WINAPI I_ScUnregisterDeviceNotification( HDEVNOTIFY handle )
TRACE("%p\n", handle);
+ if (!handle)
+ return FALSE;
+
EnterCriticalSection( &service_cs );
list_remove( ®istration->entry );
LeaveCriticalSection(&service_cs);
diff --git a/dlls/user32/tests/Makefile.in b/dlls/user32/tests/Makefile.in
index dd101d69f3..43f843bd09 100644
--- a/dlls/user32/tests/Makefile.in
+++ b/dlls/user32/tests/Makefile.in
@@ -15,6 +15,7 @@ C_SRCS = \
input.c \
listbox.c \
menu.c \
+ misc.c \
monitor.c \
msg.c \
resource.c \
diff --git a/dlls/user32/tests/misc.c b/dlls/user32/tests/misc.c
new file mode 100644
index 0000000000..1f55a65a3e
--- /dev/null
+++ b/dlls/user32/tests/misc.c
@@ -0,0 +1,33 @@
+/*
+ * Unit test suite for misc functions.
+ *
+ * Copyright 2020 Arkadiusz Hiler
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
+ */
+
+#include "wine/test.h"
+#include "winuser.h"
+
+static void test_UnregisterDeviceNotification(void)
+{
+ BOOL ret = UnregisterDeviceNotification(NULL);
+ ok(ret == FALSE, "Unregistering NULL Device Notification returned: %d\n", ret);
+}
+
+START_TEST(misc)
+{
+ test_UnregisterDeviceNotification();
+}
--
2.26.2
More information about the wine-devel
mailing list