Aric Stewart : msi: Do not crash in MsiGetUserInfo if org, user or serial are not present, instead return USERINFOSTATE_ABSENT.

Alexandre Julliard julliard at wine.codeweavers.com
Thu Apr 12 09:59:59 CDT 2007


Module: wine
Branch: master
Commit: b46ab0b8cb19c7728397b0a5865a1d4f0f5a63c8
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=b46ab0b8cb19c7728397b0a5865a1d4f0f5a63c8

Author: Aric Stewart <aric at codeweavers.com>
Date:   Thu Apr 12 14:46:43 2007 +0900

msi: Do not crash in MsiGetUserInfo if org, user or serial are not present, instead return USERINFOSTATE_ABSENT.

---

 dlls/msi/msi.c |   32 +++++++++++++++++++++++---------
 1 files changed, 23 insertions(+), 9 deletions(-)

diff --git a/dlls/msi/msi.c b/dlls/msi/msi.c
index 2cb4848..ae67b75 100644
--- a/dlls/msi/msi.c
+++ b/dlls/msi/msi.c
@@ -1562,15 +1562,29 @@ static USERINFOSTATE WINAPI MSI_GetUserInfo(LPCWSTR szProduct,
 
     state = USERINFOSTATE_PRESENT;
 
-    r = msi_strcpy_to_awstring( user, lpUserNameBuf, pcchUserNameBuf );
-    if (r == ERROR_MORE_DATA)
-        state = USERINFOSTATE_MOREDATA;
-    r = msi_strcpy_to_awstring( org, lpOrgNameBuf, pcchOrgNameBuf );
-    if (r == ERROR_MORE_DATA)
-        state = USERINFOSTATE_MOREDATA;
-    r = msi_strcpy_to_awstring( serial, lpSerialBuf, pcchSerialBuf );
-    if (r == ERROR_MORE_DATA)
-        state = USERINFOSTATE_MOREDATA;
+    if (user)
+    {
+        r = msi_strcpy_to_awstring( user, lpUserNameBuf, pcchUserNameBuf );
+        if (r == ERROR_MORE_DATA)
+            state = USERINFOSTATE_MOREDATA;
+    }
+    else
+        state = USERINFOSTATE_ABSENT;
+    if (org)
+    {
+        r = msi_strcpy_to_awstring( org, lpOrgNameBuf, pcchOrgNameBuf );
+        if (r == ERROR_MORE_DATA && state == USERINFOSTATE_PRESENT)
+            state = USERINFOSTATE_MOREDATA;
+    }
+    /* msdn states: The user information is considered to be present even in the absence of a company name. */
+    if (serial)
+    {
+        r = msi_strcpy_to_awstring( serial, lpSerialBuf, pcchSerialBuf );
+        if (r == ERROR_MORE_DATA && state == USERINFOSTATE_PRESENT)
+            state = USERINFOSTATE_MOREDATA;
+    }
+    else
+        state = USERINFOSTATE_ABSENT;
 
     msi_free( user );
     msi_free( org );




More information about the wine-cvs mailing list