>From 3034dc9ffd8150848c6db17ad75cafd0cfc3ca4c Mon Sep 17 00:00:00 2001 From: Paul Vriens Date: Tue, 23 Sep 2008 22:57:24 +0200 Subject: [PATCH] Don't crash on NT4 --- dlls/crypt32/tests/msg.c | 135 ++++++++++++++++++++++++---------------------- 1 files changed, 71 insertions(+), 64 deletions(-) diff --git a/dlls/crypt32/tests/msg.c b/dlls/crypt32/tests/msg.c index e4a3849..0992c78 100644 --- a/dlls/crypt32/tests/msg.c +++ b/dlls/crypt32/tests/msg.c @@ -2563,74 +2563,81 @@ static void test_msg_control(void) ret = CryptMsgControl(NULL, 0, 0, NULL); */ - /* Data encode messages don't allow any sort of control.. */ - msg = CryptMsgOpenToEncode(PKCS_7_ASN_ENCODING, 0, CMSG_DATA, NULL, NULL, - NULL); - /* either with no prior update.. */ - for (i = 1; have_nt && (i <= CMSG_CTRL_ADD_CMS_SIGNER_INFO); i++) - { - SetLastError(0xdeadbeef); - ret = CryptMsgControl(msg, 0, i, NULL); - ok(!ret && GetLastError() == E_INVALIDARG, - "Expected E_INVALIDARG, got %08x\n", GetLastError()); - } - ret = CryptMsgUpdate(msg, NULL, 0, TRUE); - /* or after an update. */ - for (i = 1; have_nt && (i <= CMSG_CTRL_ADD_CMS_SIGNER_INFO); i++) + if (0) { - SetLastError(0xdeadbeef); - ret = CryptMsgControl(msg, 0, i, NULL); - ok(!ret && GetLastError() == E_INVALIDARG, - "Expected E_INVALIDARG, got %08x\n", GetLastError()); - } - CryptMsgClose(msg); + /* Data encode messages don't allow any sort of control.. */ - /* Hash encode messages don't allow any sort of control.. */ - hashInfo.cbSize = sizeof(hashInfo); - hashInfo.HashAlgorithm.pszObjId = oid_rsa_md5; - msg = CryptMsgOpenToEncode(PKCS_7_ASN_ENCODING, 0, CMSG_HASHED, &hashInfo, - NULL, NULL); - /* either with no prior update.. */ - for (i = 1; have_nt && (i <= CMSG_CTRL_ADD_CMS_SIGNER_INFO); i++) - { - SetLastError(0xdeadbeef); - ret = CryptMsgControl(msg, 0, i, NULL); - ok(!ret && GetLastError() == E_INVALIDARG, - "Expected E_INVALIDARG, got %08x\n", GetLastError()); - } - ret = CryptMsgUpdate(msg, NULL, 0, TRUE); - /* or after an update. */ - for (i = 1; have_nt && (i <= CMSG_CTRL_ADD_CMS_SIGNER_INFO); i++) - { - SetLastError(0xdeadbeef); - ret = CryptMsgControl(msg, 0, i, NULL); - ok(!ret && GetLastError() == E_INVALIDARG, - "Expected E_INVALIDARG, got %08x\n", GetLastError()); - } - CryptMsgClose(msg); + /* NT4 crashes on CryptMsgControl when passing something for the control + * type and NULL for the control parameter + */ + msg = CryptMsgOpenToEncode(PKCS_7_ASN_ENCODING, 0, CMSG_DATA, NULL, NULL, + NULL); + /* either with no prior update.. */ + for (i = 1; have_nt && (i <= CMSG_CTRL_ADD_CMS_SIGNER_INFO); i++) + { + SetLastError(0xdeadbeef); + ret = CryptMsgControl(msg, 0, i, NULL); + ok(!ret && GetLastError() == E_INVALIDARG, + "Expected E_INVALIDARG, got %08x\n", GetLastError()); + } + ret = CryptMsgUpdate(msg, NULL, 0, TRUE); + /* or after an update. */ + for (i = 1; have_nt && (i <= CMSG_CTRL_ADD_CMS_SIGNER_INFO); i++) + { + SetLastError(0xdeadbeef); + ret = CryptMsgControl(msg, 0, i, NULL); + ok(!ret && GetLastError() == E_INVALIDARG, + "Expected E_INVALIDARG, got %08x\n", GetLastError()); + } + CryptMsgClose(msg); - /* Signed encode messages likewise don't allow any sort of control.. */ - signInfo.cbSize = sizeof(signInfo); - msg = CryptMsgOpenToEncode(PKCS_7_ASN_ENCODING, 0, CMSG_SIGNED, &signInfo, - NULL, NULL); - /* either before an update.. */ - for (i = 1; have_nt && (i <= CMSG_CTRL_ADD_CMS_SIGNER_INFO); i++) - { - SetLastError(0xdeadbeef); - ret = CryptMsgControl(msg, 0, i, NULL); - ok(!ret && GetLastError() == E_INVALIDARG, - "Expected E_INVALIDARG, got %08x\n", GetLastError()); - } - ret = CryptMsgUpdate(msg, NULL, 0, TRUE); - /* or after an update. */ - for (i = 1; have_nt && (i <= CMSG_CTRL_ADD_CMS_SIGNER_INFO); i++) - { - SetLastError(0xdeadbeef); - ret = CryptMsgControl(msg, 0, i, NULL); - ok(!ret && GetLastError() == E_INVALIDARG, - "Expected E_INVALIDARG, got %08x\n", GetLastError()); + /* Hash encode messages don't allow any sort of control.. */ + hashInfo.cbSize = sizeof(hashInfo); + hashInfo.HashAlgorithm.pszObjId = oid_rsa_md5; + msg = CryptMsgOpenToEncode(PKCS_7_ASN_ENCODING, 0, CMSG_HASHED, &hashInfo, + NULL, NULL); + /* either with no prior update.. */ + for (i = 1; have_nt && (i <= CMSG_CTRL_ADD_CMS_SIGNER_INFO); i++) + { + SetLastError(0xdeadbeef); + ret = CryptMsgControl(msg, 0, i, NULL); + ok(!ret && GetLastError() == E_INVALIDARG, + "Expected E_INVALIDARG, got %08x\n", GetLastError()); + } + ret = CryptMsgUpdate(msg, NULL, 0, TRUE); + /* or after an update. */ + for (i = 1; have_nt && (i <= CMSG_CTRL_ADD_CMS_SIGNER_INFO); i++) + { + SetLastError(0xdeadbeef); + ret = CryptMsgControl(msg, 0, i, NULL); + ok(!ret && GetLastError() == E_INVALIDARG, + "Expected E_INVALIDARG, got %08x\n", GetLastError()); + } + CryptMsgClose(msg); + + /* Signed encode messages likewise don't allow any sort of control.. */ + signInfo.cbSize = sizeof(signInfo); + msg = CryptMsgOpenToEncode(PKCS_7_ASN_ENCODING, 0, CMSG_SIGNED, &signInfo, + NULL, NULL); + /* either before an update.. */ + for (i = 1; have_nt && (i <= CMSG_CTRL_ADD_CMS_SIGNER_INFO); i++) + { + SetLastError(0xdeadbeef); + ret = CryptMsgControl(msg, 0, i, NULL); + ok(!ret && GetLastError() == E_INVALIDARG, + "Expected E_INVALIDARG, got %08x\n", GetLastError()); + } + ret = CryptMsgUpdate(msg, NULL, 0, TRUE); + /* or after an update. */ + for (i = 1; have_nt && (i <= CMSG_CTRL_ADD_CMS_SIGNER_INFO); i++) + { + SetLastError(0xdeadbeef); + ret = CryptMsgControl(msg, 0, i, NULL); + ok(!ret && GetLastError() == E_INVALIDARG, + "Expected E_INVALIDARG, got %08x\n", GetLastError()); + } + CryptMsgClose(msg); } - CryptMsgClose(msg); /* Decode messages behave a bit differently. */ msg = CryptMsgOpenToDecode(PKCS_7_ASN_ENCODING, 0, 0, 0, NULL, NULL); -- 1.5.5.1