crypt32: Fix encoding OIDs with only two components.

This commit is contained in:
Juan Lang 2008-12-19 15:40:35 -08:00 committed by Alexandre Julliard
parent fa65c3f634
commit 519478e048
2 changed files with 11 additions and 1 deletions

View File

@ -796,7 +796,7 @@ BOOL WINAPI CRYPT_AsnEncodeOid(DWORD dwCertEncodingType,
const char *ptr;
int val1, val2;
if (sscanf(pszObjId, "%d.%d.%n", &val1, &val2, &firstPos) != 2)
if (sscanf(pszObjId, "%d.%d%n", &val1, &val2, &firstPos) != 2)
{
SetLastError(CRYPT_E_ASN1_ERROR);
return FALSE;
@ -804,6 +804,11 @@ BOOL WINAPI CRYPT_AsnEncodeOid(DWORD dwCertEncodingType,
bytesNeeded++;
firstByte = val1 * 40 + val2;
ptr = pszObjId + firstPos;
if (*ptr == '.')
{
ptr++;
firstPos++;
}
while (ret && *ptr)
{
int pos;

View File

@ -2536,17 +2536,22 @@ static CERT_EXTENSION criticalExt =
{ oid_basic_constraints2, TRUE, { 8, crit_ext_data } };
static CERT_EXTENSION nonCriticalExt =
{ oid_basic_constraints2, FALSE, { 8, noncrit_ext_data } };
static CHAR oid_short[] = "1.1";
static CERT_EXTENSION extWithShortOid =
{ oid_short, FALSE, { 0, NULL } };
static const BYTE ext0[] = { 0x30,0x00 };
static const BYTE ext1[] = { 0x30,0x14,0x30,0x12,0x06,0x03,0x55,0x1d,0x13,0x01,0x01,
0xff,0x04,0x08,0x30,0x06,0x01,0x01,0xff,0x02,0x01,0x01 };
static const BYTE ext2[] = { 0x30,0x11,0x30,0x0f,0x06,0x03,0x55,0x1d,0x13,0x04,
0x08,0x30,0x06,0x01,0x01,0xff,0x02,0x01,0x01 };
static const BYTE ext3[] = { 0x30,0x07,0x30,0x05,0x06,0x01,0x29,0x04,0x00 };
static const struct encodedExtensions exts[] = {
{ { 0, NULL }, ext0 },
{ { 1, &criticalExt }, ext1 },
{ { 1, &nonCriticalExt }, ext2 },
{ { 1, &extWithShortOid }, ext3 }
};
static void test_encodeExtensions(DWORD dwEncoding)