Commit 382d0679 authored by James Hawkins's avatar James Hawkins Committed by Alexandre Julliard

crypt32: Simplify CRYPT_AsnDecodeUnicodeNameValueInternal, getting rid of a warning.

parent a9670e37
...@@ -1511,67 +1511,65 @@ static BOOL WINAPI CRYPT_AsnDecodeUnicodeNameValueInternal( ...@@ -1511,67 +1511,65 @@ static BOOL WINAPI CRYPT_AsnDecodeUnicodeNameValueInternal(
break; break;
default: default:
SetLastError(CRYPT_E_ASN1_BADTAG); SetLastError(CRYPT_E_ASN1_BADTAG);
return FALSE;
}
if (!value)
*pcbStructInfo = bytesNeeded;
else if (*pcbStructInfo < bytesNeeded)
{
*pcbStructInfo = bytesNeeded;
SetLastError(ERROR_MORE_DATA);
ret = FALSE; ret = FALSE;
} }
if (ret) else
{ {
if (!value) *pcbStructInfo = bytesNeeded;
*pcbStructInfo = bytesNeeded; value->dwValueType = valueType;
else if (*pcbStructInfo < bytesNeeded) if (dataLen)
{
*pcbStructInfo = bytesNeeded;
SetLastError(ERROR_MORE_DATA);
ret = FALSE;
}
else
{ {
*pcbStructInfo = bytesNeeded; DWORD i;
value->dwValueType = valueType; LPWSTR str = (LPWSTR)value->Value.pbData;
if (dataLen)
{
DWORD i;
LPWSTR str = (LPWSTR)value->Value.pbData;
assert(value->Value.pbData); assert(value->Value.pbData);
switch (pbEncoded[0]) switch (pbEncoded[0])
{
case ASN_NUMERICSTRING:
case ASN_PRINTABLESTRING:
case ASN_IA5STRING:
case ASN_T61STRING:
case ASN_VIDEOTEXSTRING:
case ASN_GRAPHICSTRING:
case ASN_VISIBLESTRING:
case ASN_GENERALSTRING:
value->Value.cbData = dataLen * 2;
for (i = 0; i < dataLen; i++)
str[i] = pbEncoded[1 + lenBytes + i];
break;
case ASN_UNIVERSALSTRING:
value->Value.cbData = dataLen / 2;
for (i = 0; i < dataLen / 4; i++)
str[i] = (pbEncoded[1 + lenBytes + 2 * i + 2] << 8)
| pbEncoded[1 + lenBytes + 2 * i + 3];
break;
case ASN_BMPSTRING:
value->Value.cbData = dataLen;
for (i = 0; i < dataLen / 2; i++)
str[i] = (pbEncoded[1 + lenBytes + 2 * i] << 8) |
pbEncoded[1 + lenBytes + 2 * i + 1];
break;
case ASN_UTF8STRING:
value->Value.cbData = MultiByteToWideChar(CP_UTF8, 0,
(LPSTR)pbEncoded + 1 + lenBytes, dataLen,
str, bytesNeeded - sizeof(CERT_NAME_VALUE)) * 2;
break;
}
}
else
{ {
value->Value.cbData = 0; case ASN_NUMERICSTRING:
value->Value.pbData = NULL; case ASN_PRINTABLESTRING:
case ASN_IA5STRING:
case ASN_T61STRING:
case ASN_VIDEOTEXSTRING:
case ASN_GRAPHICSTRING:
case ASN_VISIBLESTRING:
case ASN_GENERALSTRING:
value->Value.cbData = dataLen * 2;
for (i = 0; i < dataLen; i++)
str[i] = pbEncoded[1 + lenBytes + i];
break;
case ASN_UNIVERSALSTRING:
value->Value.cbData = dataLen / 2;
for (i = 0; i < dataLen / 4; i++)
str[i] = (pbEncoded[1 + lenBytes + 2 * i + 2] << 8)
| pbEncoded[1 + lenBytes + 2 * i + 3];
break;
case ASN_BMPSTRING:
value->Value.cbData = dataLen;
for (i = 0; i < dataLen / 2; i++)
str[i] = (pbEncoded[1 + lenBytes + 2 * i] << 8) |
pbEncoded[1 + lenBytes + 2 * i + 1];
break;
case ASN_UTF8STRING:
value->Value.cbData = MultiByteToWideChar(CP_UTF8, 0,
(LPSTR)pbEncoded + 1 + lenBytes, dataLen,
str, bytesNeeded - sizeof(CERT_NAME_VALUE)) * 2;
break;
} }
} }
else
{
value->Value.cbData = 0;
value->Value.pbData = NULL;
}
} }
} }
return ret; return ret;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment