crypt32: Fix CryptBinaryToString return value on short base64 buffer.

Signed-off-by: Jeff Smith <whydoubt@gmail.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Jeff Smith 2019-10-09 12:53:54 -05:00 committed by Alexandre Julliard
parent 6cbedfa65b
commit e0708d0601
2 changed files with 2 additions and 4 deletions

View File

@ -240,7 +240,7 @@ static BOOL BinaryToBase64A(const BYTE *pbBinary,
else else
{ {
*pcchString = charsNeeded; *pcchString = charsNeeded;
SetLastError(ERROR_INSUFFICIENT_BUFFER); SetLastError(ERROR_MORE_DATA);
ret = FALSE; ret = FALSE;
} }
} }
@ -460,7 +460,7 @@ static BOOL BinaryToBase64W(const BYTE *pbBinary,
else else
{ {
*pcchString = charsNeeded; *pcchString = charsNeeded;
SetLastError(ERROR_INSUFFICIENT_BUFFER); SetLastError(ERROR_MORE_DATA);
ret = FALSE; ret = FALSE;
} }
} }

View File

@ -134,7 +134,6 @@ static void encodeAndCompareBase64_A(const BYTE *toEncode, DWORD toEncodeLen,
strLen2 = strLen - 1; strLen2 = strLen - 1;
str[0] = 0x12; str[0] = 0x12;
ret = CryptBinaryToStringA(toEncode, toEncodeLen, format, str, &strLen2); ret = CryptBinaryToStringA(toEncode, toEncodeLen, format, str, &strLen2);
todo_wine
ok((!ret && GetLastError() == ERROR_MORE_DATA) || broken(ret) /* XP */, "CryptBinaryToStringA failed %d, error %d.\n", ok((!ret && GetLastError() == ERROR_MORE_DATA) || broken(ret) /* XP */, "CryptBinaryToStringA failed %d, error %d.\n",
ret, GetLastError()); ret, GetLastError());
ok(strLen2 == strLen || broken(strLen2 == strLen - 1), "Expected length %d, got %d\n", strLen, strLen2); ok(strLen2 == strLen || broken(strLen2 == strLen - 1), "Expected length %d, got %d\n", strLen, strLen2);
@ -207,7 +206,6 @@ static void encode_compare_base64_W(const BYTE *toEncode, DWORD toEncodeLen, DWO
strLen2 = strLen - 1; strLen2 = strLen - 1;
strW[0] = 0x1234; strW[0] = 0x1234;
ret = CryptBinaryToStringW(toEncode, toEncodeLen, format, strW, &strLen2); ret = CryptBinaryToStringW(toEncode, toEncodeLen, format, strW, &strLen2);
todo_wine
ok((!ret && GetLastError() == ERROR_MORE_DATA) || broken(ret) /* XP */, "CryptBinaryToStringW failed, %d, error %d\n", ok((!ret && GetLastError() == ERROR_MORE_DATA) || broken(ret) /* XP */, "CryptBinaryToStringW failed, %d, error %d\n",
ret, GetLastError()); ret, GetLastError());
if (headerW) if (headerW)