MSI: MsiGetComponentPath should allow null pointers for pcchBuf and
lpPathBuf
Mike McCormack
mike at codeweavers.com
Tue Feb 15 20:23:24 CST 2005
ChangeLog:
* MsiGetComponentPath should allow null pointers for pcchBuf and lpPathBuf
-------------- next part --------------
Index: dlls/msi/msi.c
===================================================================
RCS file: /home/wine/wine/dlls/msi/msi.c,v
retrieving revision 1.60
diff -u -p -r1.60 msi.c
--- dlls/msi/msi.c 10 Feb 2005 18:57:42 -0000 1.60
+++ dlls/msi/msi.c 16 Feb 2005 02:24:19 -0000
@@ -1340,41 +1340,64 @@ INSTALLSTATE WINAPI MsiGetComponentPathW
WCHAR squished_pc[GUID_SIZE];
UINT rc;
INSTALLSTATE rrc = INSTALLSTATE_UNKNOWN;
- HKEY hkey=0;
+ HKEY hkey = 0;
+ LPWSTR path = NULL;
+ DWORD sz, type;
TRACE("%s %s %p %p\n", debugstr_w(szProduct),
debugstr_w(szComponent), lpPathBuf, pcchBuf);
+ if( lpPathBuf && !pcchBuf )
+ return INSTALLSTATE_INVALIDARG;
+
squash_guid(szProduct,squished_pc);
- rc = MSIREG_OpenProductsKey(szProduct,&hkey,FALSE);
- if (rc != ERROR_SUCCESS)
+ rc = MSIREG_OpenProductsKey( szProduct, &hkey, FALSE);
+ if( rc != ERROR_SUCCESS )
goto end;
RegCloseKey(hkey);
- rc = MSIREG_OpenComponentsKey(szComponent,&hkey,FALSE);
- if (rc != ERROR_SUCCESS)
+ rc = MSIREG_OpenComponentsKey( szComponent, &hkey, FALSE);
+ if( rc != ERROR_SUCCESS )
+ goto end;
+
+ sz = 0;
+ type = 0;
+ rc = RegQueryValueExW( hkey, squished_pc, NULL, &type, NULL, &sz );
+ if( rc != ERROR_SUCCESS )
+ goto end;
+ if( type != REG_SZ )
goto end;
- *pcchBuf *= sizeof(WCHAR);
- rc = RegQueryValueExW(hkey,squished_pc,NULL,NULL,(LPVOID)lpPathBuf,
- pcchBuf);
- *pcchBuf /= sizeof(WCHAR);
+ sz += sizeof(WCHAR);
+ path = HeapAlloc( GetProcessHeap(), 0, sz );
+ if( !path )
+ goto end;
- if (rc!= ERROR_SUCCESS)
+ rc = RegQueryValueExW( hkey, squished_pc, NULL, NULL, (LPVOID) path, &sz );
+ if( rc != ERROR_SUCCESS )
goto end;
TRACE("found path of (%s:%s)(%s)\n", debugstr_w(szComponent),
- debugstr_w(szProduct), debugstr_w(lpPathBuf));
+ debugstr_w(szProduct), debugstr_w(path));
FIXME("Only working for installed files, not registry keys\n");
- if (GetFileAttributesW(lpPathBuf) != INVALID_FILE_ATTRIBUTES)
+ if ( GetFileAttributesW(path) != INVALID_FILE_ATTRIBUTES )
rrc = INSTALLSTATE_LOCAL;
else
rrc = INSTALLSTATE_ABSENT;
+ if( pcchBuf )
+ {
+ sz = sz / sizeof(WCHAR);
+ if( *pcchBuf >= sz )
+ strcpyW( lpPathBuf, path );
+ *pcchBuf = sz;
+ }
+
end:
+ HeapFree(GetProcessHeap(), 0, path );
RegCloseKey(hkey);
return rrc;
}
More information about the wine-patches
mailing list