shell32 patch 23 a

Martin Fuchs martin-fuchs at gmx.net
Sat Feb 28 15:00:33 CST 2004


Changelog:
fix buffer length usage for RegQueryValueW() calls at various places
(The buffer length for RegQueryValueW() is given in bytes, not in characters!)


Index: shlexec.c
===================================================================
RCS file: /home/wine/wine/dlls/shell32/shlexec.c,v
retrieving revision 1.29
diff -u -p -d -r1.29 shlexec.c
--- shlexec.c	12 Feb 2004 20:04:09 -0000	1.29
+++ shlexec.c	28 Feb 2004 20:56:53 -0000
@@ -250,7 +250,7 @@ static BOOL SHELL_TryAppPathW( LPCWSTR s
     res = RegOpenKeyExW(HKEY_LOCAL_MACHINE, buffer, 0, KEY_READ, &hkApp);
     if (res) goto end;
 
-    len = MAX_PATH;
+    len = MAX_PATH*sizeof(WCHAR);
     res = RegQueryValueW(hkApp, NULL, lpResult, &len);
     if (res) goto end;
     found = TRUE;
@@ -292,9 +292,9 @@ static UINT SHELL_FindExecutable(LPCWSTR
     WCHAR *extension = NULL; /* pointer to file extension */
     WCHAR wtmpext[5];        /* local copy to mung as we please */
     WCHAR filetype[256];     /* registry name for this filetype */
-    LONG  filetypelen = 256; /* length of above */
+    LONG  filetypelen = sizeof(filetype); /* length of above */
     WCHAR command[256];      /* command from registry */
-    LONG  commandlen = 256;  /* This is the most DOS can handle :) */
+    LONG  commandlen = sizeof(command);  /* This is the most DOS can handle :) */
     WCHAR wBuffer[256];      /* Used to GetProfileString */
     UINT  retval = 31;       /* default - 'No association was found' */
     WCHAR *tok;              /* token pointer */
@@ -389,6 +389,7 @@ static UINT SHELL_FindExecutable(LPCWSTR
     if (RegQueryValueW(HKEY_CLASSES_ROOT, wtmpext, filetype, 
 			&filetypelen) == ERROR_SUCCESS)
     {
+	filetypelen /= sizeof(WCHAR);
 	filetype[filetypelen] = '\0';
 	TRACE("File type: %s\n", debugstr_w(filetype));
 
@@ -400,11 +401,12 @@ static UINT SHELL_FindExecutable(LPCWSTR
 	if (RegQueryValueW(HKEY_CLASSES_ROOT, filetype, command,
                            &commandlen) == ERROR_SUCCESS)
 	{
+	    commandlen /= sizeof(WCHAR);
             if (key) strcpyW(key, filetype);
 #if 0
             LPWSTR tmp;
             WCHAR param[256];
-	    LONG paramlen = 256;
+	    LONG paramlen = sizeof(param);
             static const WCHAR wSpace[] = {' ',0};
 
             /* FIXME: it seems all Windows version don't behave the same here.
@@ -421,6 +423,7 @@ static UINT SHELL_FindExecutable(LPCWSTR
 	    if (RegQueryValueW(HKEY_CLASSES_ROOT, filetype, param,
 					 &paramlen) == ERROR_SUCCESS)
 	    {
+		paramlen /= sizeof(WCHAR);
                 strcatW(command, wSpace);
                 strcatW(command, param);
                 commandlen += paramlen;
@@ -501,7 +504,7 @@ static unsigned dde_connect(WCHAR* key, 
     unsigned    ret = 31;
 
     strcpyW(endkey, wApplication);
-    applen = sizeof(app)/sizeof(WCHAR);
+    applen = sizeof(app);
     if (RegQueryValueW(HKEY_CLASSES_ROOT, key, app, &applen) != ERROR_SUCCESS)
     {
         FIXME("default app name NIY %s\n", debugstr_w(key));
@@ -509,7 +512,7 @@ static unsigned dde_connect(WCHAR* key, 
     }
 
     strcpyW(endkey, wTopic);
-    topiclen = sizeof(topic)/sizeof(WCHAR);
+    topiclen = sizeof(topic);
     if (RegQueryValueW(HKEY_CLASSES_ROOT, key, topic, &topiclen) != ERROR_SUCCESS)
     {
         static const WCHAR wSystem[] = {'S','y','s','t','e','m',0};
@@ -544,7 +547,7 @@ static unsigned dde_connect(WCHAR* key, 
             goto error;
         }
         strcpyW(endkey, wIfexec);
-        ifexeclen = sizeof(ifexec)/sizeof(WCHAR);
+        ifexeclen = sizeof(ifexec);
         if (RegQueryValueW(HKEY_CLASSES_ROOT, key, ifexec, &ifexeclen) == ERROR_SUCCESS)
         {
             exec = ifexec;
@@ -569,7 +572,7 @@ static UINT execute_from_key(LPWSTR key,
                              LPSHELLEXECUTEINFOW sei, SHELL_ExecuteW32 execfunc)
 {
     WCHAR cmd[1024] = {0};
-    LONG cmdlen = 1024;
+    LONG cmdlen = sizeof(cmd);
     UINT retval = 31;
 
     /* Get the application for the registry */
@@ -579,7 +582,7 @@ static UINT execute_from_key(LPWSTR key,
 	static const WCHAR wDdeexec[] = {'d','d','e','e','x','e','c',0};
         LPWSTR tmp;
         WCHAR param[256] = {0};
-        LONG paramlen = 256;
+        LONG paramlen = sizeof(param);
 
         /* Get the parameters needed by the application
            from the associated ddeexec key */
@@ -595,6 +598,7 @@ static UINT execute_from_key(LPWSTR key,
         else
         {
             /* Is there a replace() function anywhere? */
+            cmdlen /= sizeof(WCHAR);
             cmd[cmdlen] = '\0';
             SHELL_ArgifyW(param, sizeof(param)/sizeof(WCHAR), cmd, lpFile);
             retval = execfunc(param, env, sei, FALSE);





More information about the wine-patches mailing list