[PATCH] msi: allocate correct buffer size (Coverity)

Marcus Meissner marcus at jet.franken.de
Sat Jun 18 03:02:43 CDT 2016


713180 Out-of-bounds access
713179 Out-of-bounds access

We pass in a size of 1 character more to MBtoWC than we allocated earlier.

Signed-off-by: Marcus Meissner <marcus at jet.franken.de>
---
 dlls/msi/registry.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/dlls/msi/registry.c b/dlls/msi/registry.c
index f3b1ddf..5357d00 100644
--- a/dlls/msi/registry.c
+++ b/dlls/msi/registry.c
@@ -1242,7 +1242,7 @@ UINT WINAPI MsiEnumComponentsExA( LPCSTR user_sid, DWORD ctx, DWORD index, CHAR
 
     if (sid && !sid_len) return ERROR_INVALID_PARAMETER;
     if (user_sid && !(user_sidW = strdupAtoW( user_sid ))) return ERROR_OUTOFMEMORY;
-    if (sid && !(sidW = msi_alloc( *sid_len * sizeof(WCHAR) )))
+    if (sid && !(sidW = msi_alloc( (*sid_len + 1) * sizeof(WCHAR) )))
     {
         msi_free( user_sidW );
         return ERROR_OUTOFMEMORY;
@@ -2267,7 +2267,7 @@ UINT WINAPI MsiEnumProductsExA( LPCSTR product, LPCSTR usersid, DWORD ctx, DWORD
         msi_free( productW );
         return ERROR_OUTOFMEMORY;
     }
-    if (sid && !(sidW = msi_alloc( *sid_len * sizeof(WCHAR) )))
+    if (sid && !(sidW = msi_alloc( (*sid_len + 1) * sizeof(WCHAR) )))
     {
         msi_free( usersidW );
         msi_free( productW );
-- 
2.8.4




More information about the wine-patches mailing list