Author: tfaber
Date: Tue Apr 12 13:01:35 2016
New Revision: 71149
URL:
http://svn.reactos.org/svn/reactos?rev=71149&view=rev
Log:
[ADVAPI32]
- Fix null termination in RegQueryInfoKeyA. Based on Wine commit 303daeef by Alexandre
Juilliard.
Modified:
trunk/reactos/dll/win32/advapi32/reg/reg.c
trunk/rostests/winetests/advapi32/registry.c
Modified: trunk/reactos/dll/win32/advapi32/reg/reg.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/advapi32/reg/reg…
==============================================================================
--- trunk/reactos/dll/win32/advapi32/reg/reg.c [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/advapi32/reg/reg.c [iso-8859-1] Tue Apr 12 13:01:35 2016
@@ -3645,7 +3645,7 @@
FALSE);
ErrorCode = RtlNtStatusToDosError(Status);
cClass = AnsiString.Length;
- lpClass[*lpcClass - 1] = 0;
+ lpClass[cClass] = ANSI_NULL;
}
if (lpcClass != NULL)
Modified: trunk/rostests/winetests/advapi32/registry.c
URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/winetests/advapi32/regist…
==============================================================================
--- trunk/rostests/winetests/advapi32/registry.c [iso-8859-1] (original)
+++ trunk/rostests/winetests/advapi32/registry.c [iso-8859-1] Tue Apr 12 13:01:35 2016
@@ -2,7 +2,7 @@
* Unit tests for registry functions
*
* Copyright (c) 2002 Alexandre Julliard
- * Copyright (c) 2010 André Hentschel
+ * Copyright (c) 2010 André Hentschel
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -1997,8 +1997,30 @@
"classbuffer = \"%.*s\", expected %s\n",
(int)sizeof(classbuffer), classbuffer, expectbuffer);
+ memset(classbuffer, 0x55, sizeof(classbuffer));
+ classlen = 0xdeadbeef;
+ ret = RegQueryInfoKeyA(subkey, classbuffer, &classlen, NULL, NULL, NULL, NULL,
NULL, NULL, NULL, NULL, NULL);
+ ok(ret == ERROR_SUCCESS, "ret = %d\n", ret);
+ ok(classlen == sizeof(subkey_class) - 1, "classlen = %u\n", classlen);
+ memset(expectbuffer, 0x55, sizeof(expectbuffer));
+ strcpy(expectbuffer, subkey_class);
+ ok(!memcmp(classbuffer, expectbuffer, sizeof(classbuffer)),
+ "classbuffer = \"%.*s\", expected %s\n",
+ (int)sizeof(classbuffer), classbuffer, expectbuffer);
+
memset(classbufferW, 0x55, sizeof(classbufferW));
classlen = sizeof(subkey_class);
+ ret = RegQueryInfoKeyW(subkey, classbufferW, &classlen, NULL, NULL, NULL, NULL,
NULL, NULL, NULL, NULL, NULL);
+ ok(ret == ERROR_SUCCESS, "ret = %d\n", ret);
+ ok(classlen == sizeof(subkey_class) - 1, "classlen = %u\n", classlen);
+ memset(expectbufferW, 0x55, sizeof(expectbufferW));
+ lstrcpyW(expectbufferW, subkey_classW);
+ ok(!memcmp(classbufferW, expectbufferW, sizeof(classbufferW)),
+ "classbufferW = %s, expected %s\n",
+ wine_dbgstr_wn(classbufferW, sizeof(classbufferW) / sizeof(WCHAR)),
wine_dbgstr_w(expectbufferW));
+
+ memset(classbufferW, 0x55, sizeof(classbufferW));
+ classlen = 0xdeadbeef;
ret = RegQueryInfoKeyW(subkey, classbufferW, &classlen, NULL, NULL, NULL, NULL,
NULL, NULL, NULL, NULL, NULL);
ok(ret == ERROR_SUCCESS, "ret = %d\n", ret);
ok(classlen == sizeof(subkey_class) - 1, "classlen = %u\n", classlen);