https://git.reactos.org/?p=reactos.git;a=commitdiff;h=abc90fa5a6d3d17e89ad1…
commit abc90fa5a6d3d17e89ad12b8abae16649973ab3f
Author: Amine Khaldi <amine.khaldi(a)reactos.org>
AuthorDate: Sun Apr 1 13:16:11 2018 +0100
Commit: Amine Khaldi <amine.khaldi(a)reactos.org>
CommitDate: Sun Apr 1 13:16:11 2018 +0100
[ADVAPI32] Sync cred.c with Wine Staging 3.3. CORE-14434
---
dll/win32/advapi32/wine/cred.c | 86 +++++++++++++++++++++++++++++++++++-------
media/doc/README.WINE | 2 +-
2 files changed, 74 insertions(+), 14 deletions(-)
diff --git a/dll/win32/advapi32/wine/cred.c b/dll/win32/advapi32/wine/cred.c
index 69639a4ffb..da2149d83d 100644
--- a/dll/win32/advapi32/wine/cred.c
+++ b/dll/win32/advapi32/wine/cred.c
@@ -18,9 +18,34 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
+#ifdef __REACTOS__
#include <advapi32.h>
#include <wincred.h>
+#else
+#include <stdarg.h>
+#include <time.h>
+#include <limits.h>
+
+#ifdef __APPLE__
+# include <Security/SecKeychain.h>
+# include <Security/SecKeychainItem.h>
+# include <Security/SecKeychainSearch.h>
+#endif
+
+#include "windef.h"
+#include "winbase.h"
+#include "winreg.h"
+#include "wincred.h"
+#include "winternl.h"
+
+#include "crypt.h"
+
+#include "wine/unicode.h"
+#include "wine/debug.h"
+
+#include "advapi32_misc.h"
+#endif /* __REACTOS__ */
WINE_DEFAULT_DEBUG_CHANNEL(cred);
@@ -94,14 +119,19 @@ static DWORD registry_read_credential(HKEY hkey, PCREDENTIALW
credential,
credential->TargetName = (LPWSTR)buffer;
ret = RegQueryValueExW(hkey, NULL, 0, &type,
(LPVOID)credential->TargetName,
&count);
+#ifdef __REACTOS__
if (ret != ERROR_SUCCESS)
return ret;
else if (type != REG_SZ)
return ERROR_REGISTRY_CORRUPT;
+#else
+ if (ret != ERROR_SUCCESS || type != REG_SZ) return ret;
+#endif
buffer += count;
}
ret = RegQueryValueExW(hkey, wszCommentValue, 0, &type, NULL, &count);
+#ifdef __REACTOS__
if (ret != ERROR_FILE_NOT_FOUND)
{
if (ret != ERROR_SUCCESS)
@@ -110,6 +140,13 @@ static DWORD registry_read_credential(HKEY hkey, PCREDENTIALW
credential,
return ERROR_REGISTRY_CORRUPT;
*len += count;
}
+#else
+ if (ret != ERROR_FILE_NOT_FOUND && ret != ERROR_SUCCESS)
+ return ret;
+ else if (type != REG_SZ)
+ return ERROR_REGISTRY_CORRUPT;
+ *len += count;
+#endif
if (credential)
{
credential->Comment = (LPWSTR)buffer;
@@ -126,6 +163,7 @@ static DWORD registry_read_credential(HKEY hkey, PCREDENTIALW
credential,
}
ret = RegQueryValueExW(hkey, wszTargetAliasValue, 0, &type, NULL, &count);
+#ifdef __REACTOS__
if (ret != ERROR_FILE_NOT_FOUND)
{
if (ret != ERROR_SUCCESS)
@@ -134,6 +172,13 @@ static DWORD registry_read_credential(HKEY hkey, PCREDENTIALW
credential,
return ERROR_REGISTRY_CORRUPT;
*len += count;
}
+#else
+ if (ret != ERROR_FILE_NOT_FOUND && ret != ERROR_SUCCESS)
+ return ret;
+ else if (type != REG_SZ)
+ return ERROR_REGISTRY_CORRUPT;
+ *len += count;
+#endif
if (credential)
{
credential->TargetAlias = (LPWSTR)buffer;
@@ -150,6 +195,7 @@ static DWORD registry_read_credential(HKEY hkey, PCREDENTIALW
credential,
}
ret = RegQueryValueExW(hkey, wszUserNameValue, 0, &type, NULL, &count);
+#ifdef __REACTOS__
if (ret != ERROR_FILE_NOT_FOUND)
{
if (ret != ERROR_SUCCESS)
@@ -158,6 +204,13 @@ static DWORD registry_read_credential(HKEY hkey, PCREDENTIALW
credential,
return ERROR_REGISTRY_CORRUPT;
*len += count;
}
+#else
+ if (ret != ERROR_FILE_NOT_FOUND && ret != ERROR_SUCCESS)
+ return ret;
+ else if (type != REG_SZ)
+ return ERROR_REGISTRY_CORRUPT;
+ *len += count;
+#endif
if (credential)
{
credential->UserName = (LPWSTR)buffer;
@@ -174,12 +227,18 @@ static DWORD registry_read_credential(HKEY hkey, PCREDENTIALW
credential,
}
ret = read_credential_blob(hkey, key_data, NULL, &count);
+#ifdef __REACTOS__
if (ret != ERROR_FILE_NOT_FOUND)
{
if (ret != ERROR_SUCCESS)
return ret;
*len += count;
}
+#else
+ if (ret != ERROR_FILE_NOT_FOUND && ret != ERROR_SUCCESS)
+ return ret;
+ *len += count;
+#endif
if (credential)
{
credential->CredentialBlob = (LPBYTE)buffer;
@@ -235,7 +294,7 @@ static DWORD mac_read_credential_from_item(SecKeychainItemRef item,
BOOL require
PCREDENTIALW credential, char *buffer,
DWORD *len)
{
- OSStatus status;
+ int status;
UInt32 i, cred_blob_len;
void *cred_blob;
WCHAR *user = NULL;
@@ -256,7 +315,7 @@ static DWORD mac_read_credential_from_item(SecKeychainItemRef item,
BOOL require
}
if (status != noErr)
{
- WARN("SecKeychainItemCopyAttributesAndData returned status %ld\n",
status);
+ WARN("SecKeychainItemCopyAttributesAndData returned status %d\n",
status);
return ERROR_NOT_FOUND;
}
@@ -353,6 +412,7 @@ static DWORD mac_read_credential_from_item(SecKeychainItemRef item,
BOOL require
case kSecCreationDateItemAttr:
TRACE("kSecCreationDateItemAttr: %.*s\n",
(int)attr_list->attr[i].length,
(char *)attr_list->attr[i].data);
+ if (!attr_list->attr[i].data) continue;
if (buffer)
{
LARGE_INTEGER win_time;
@@ -367,7 +427,7 @@ static DWORD mac_read_credential_from_item(SecKeychainItemRef item,
BOOL require
}
break;
default:
- FIXME("unhandled attribute %lu\n", attr_list->attr[i].tag);
+ FIXME("unhandled attribute %u\n",
(unsigned)attr_list->attr[i].tag);
break;
}
}
@@ -492,7 +552,7 @@ static DWORD registry_write_credential(HKEY hkey, const CREDENTIALW
*credential,
#ifdef __APPLE__
static DWORD mac_write_credential(const CREDENTIALW *credential, BOOL preserve_blob)
{
- OSStatus status;
+ int status;
SecKeychainItemRef keychain_item;
char *username, *password, *servername;
UInt32 userlen, pwlen, serverlen;
@@ -525,13 +585,13 @@ static DWORD mac_write_credential(const CREDENTIALW *credential,
BOOL preserve_b
status = SecKeychainAddGenericPassword(NULL, strlen(servername), servername,
strlen(username),
username, strlen(password), password,
&keychain_item);
if (status != noErr)
- ERR("SecKeychainAddGenericPassword returned %ld\n", status);
+ ERR("SecKeychainAddGenericPassword returned %d\n", status);
if (status == errSecDuplicateItem)
{
status = SecKeychainFindGenericPassword(NULL, strlen(servername), servername,
strlen(username),
username, NULL, NULL,
&keychain_item);
if (status != noErr)
- ERR("SecKeychainFindGenericPassword returned %ld\n", status);
+ ERR("SecKeychainFindGenericPassword returned %d\n", status);
}
heap_free(username);
heap_free(servername);
@@ -770,7 +830,7 @@ static DWORD mac_enumerate_credentials(LPCWSTR filter, PCREDENTIALW
*credentials
{
SecKeychainSearchRef search;
SecKeychainItemRef item;
- OSStatus status;
+ int status;
Boolean saved_user_interaction_allowed;
DWORD ret;
@@ -793,7 +853,7 @@ static DWORD mac_enumerate_credentials(LPCWSTR filter, PCREDENTIALW
*credentials
status = SecKeychainItemCopyAttributesAndData(item, &info, NULL,
&attr_list, NULL, NULL);
if (status != noErr)
{
- WARN("SecKeychainItemCopyAttributesAndData returned status
%ld\n", status);
+ WARN("SecKeychainItemCopyAttributesAndData returned status
%d\n", status);
continue;
}
if (buffer)
@@ -826,14 +886,14 @@ static DWORD mac_enumerate_credentials(LPCWSTR filter, PCREDENTIALW
*credentials
CFRelease(search);
}
else
- ERR("SecKeychainSearchCreateFromAttributes returned status %ld\n",
status);
+ ERR("SecKeychainSearchCreateFromAttributes returned status %d\n",
status);
SecKeychainSetUserInteractionAllowed(saved_user_interaction_allowed);
return ERROR_SUCCESS;
}
static DWORD mac_delete_credential(LPCWSTR TargetName)
{
- OSStatus status;
+ int status;
SecKeychainSearchRef search;
status = SecKeychainSearchCreateFromAttributes(NULL, kSecGenericPasswordItemClass,
NULL, &search);
if (status == noErr)
@@ -852,7 +912,7 @@ static DWORD mac_delete_credential(LPCWSTR TargetName)
status = SecKeychainItemCopyAttributesAndData(item, &info, NULL,
&attr_list, NULL, NULL);
if (status != noErr)
{
- WARN("SecKeychainItemCopyAttributesAndData returned status
%ld\n", status);
+ WARN("SecKeychainItemCopyAttributesAndData returned status
%d\n", status);
continue;
}
if (attr_list->count != 1 || attr_list->attr[0].tag !=
kSecServiceItemAttr)
@@ -1421,7 +1481,7 @@ BOOL WINAPI CredReadW(LPCWSTR TargetName, DWORD Type, DWORD Flags,
PCREDENTIALW
#ifdef __APPLE__
if (Type == CRED_TYPE_DOMAIN_PASSWORD)
{
- OSStatus status;
+ int status;
SecKeychainSearchRef search;
status = SecKeychainSearchCreateFromAttributes(NULL,
kSecGenericPasswordItemClass, NULL, &search);
if (status == noErr)
@@ -1441,7 +1501,7 @@ BOOL WINAPI CredReadW(LPCWSTR TargetName, DWORD Type, DWORD Flags,
PCREDENTIALW
len = sizeof(**Credential);
if (status != noErr)
{
- WARN("SecKeychainItemCopyAttributesAndData returned status
%ld\n", status);
+ WARN("SecKeychainItemCopyAttributesAndData returned status
%d\n", status);
continue;
}
if (attr_list->count != 1 || attr_list->attr[0].tag !=
kSecServiceItemAttr)
diff --git a/media/doc/README.WINE b/media/doc/README.WINE
index b0022d0190..e13a4a8f6b 100644
--- a/media/doc/README.WINE
+++ b/media/doc/README.WINE
@@ -257,7 +257,7 @@ reactos/sdk/lib/rtl/timerqueue.c # Partly synced with
WineStaging-1.7
reactos/sdk/lib/rtl/wait.c # Partly synced with WineStaging-1.7.55
advapi32 -
- reactos/dll/win32/advapi32/wine/cred.c # Synced to WineStaging-1.7.55
+ reactos/dll/win32/advapi32/wine/cred.c # Synced to WineStaging-3.3
reactos/dll/win32/advapi32/wine/crypt.c # Synced to WineStaging-1.7.55
reactos/dll/win32/advapi32/wine/crypt_des.c # Synced to WineStaging-1.7.55
reactos/dll/win32/advapi32/wine/crypt_lmhash.c # Synced to WineStaging-1.7.55