summaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
authortb <>2024-12-05 07:35:46 +0000
committertb <>2024-12-05 07:35:46 +0000
commit297bf27b198fe8f4124d9c397a13f4022ab27ee3 (patch)
treec0e804b51b4daaf25f4fafb98e67e15af1d8aea6 /src/lib
parent350e55c704d5fb7a9eac6ee2cdc0ae843463eca7 (diff)
downloadopenbsd-297bf27b198fe8f4124d9c397a13f4022ab27ee3.tar.gz
openbsd-297bf27b198fe8f4124d9c397a13f4022ab27ee3.tar.bz2
openbsd-297bf27b198fe8f4124d9c397a13f4022ab27ee3.zip
Apply a little bit of lipstick to PKCS7
Makes the setting and getting of detached signatures more symmetric and avoids a NULL access. ok jsing
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/libcrypto/pkcs7/pk7_lib.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/src/lib/libcrypto/pkcs7/pk7_lib.c b/src/lib/libcrypto/pkcs7/pk7_lib.c
index 59f348e234..aa48c269ea 100644
--- a/src/lib/libcrypto/pkcs7/pk7_lib.c
+++ b/src/lib/libcrypto/pkcs7/pk7_lib.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: pk7_lib.c,v 1.28 2023/11/09 19:08:07 tb Exp $ */ 1/* $OpenBSD: pk7_lib.c,v 1.29 2024/12/05 07:35:46 tb Exp $ */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) 2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved. 3 * All rights reserved.
4 * 4 *
@@ -70,13 +70,17 @@ long
70PKCS7_ctrl(PKCS7 *p7, int cmd, long larg, char *parg) 70PKCS7_ctrl(PKCS7 *p7, int cmd, long larg, char *parg)
71{ 71{
72 int nid; 72 int nid;
73 long ret; 73 long ret = 0;
74 74
75 nid = OBJ_obj2nid(p7->type); 75 nid = OBJ_obj2nid(p7->type);
76 76
77 switch (cmd) { 77 switch (cmd) {
78 case PKCS7_OP_SET_DETACHED_SIGNATURE: 78 case PKCS7_OP_SET_DETACHED_SIGNATURE:
79 if (nid == NID_pkcs7_signed) { 79 if (nid == NID_pkcs7_signed) {
80 if (p7->d.sign == NULL) {
81 PKCS7error(PKCS7_R_NO_CONTENT);
82 break;
83 }
80 ret = p7->detached = (int)larg; 84 ret = p7->detached = (int)larg;
81 if (ret && PKCS7_type_is_data(p7->d.sign->contents)) { 85 if (ret && PKCS7_type_is_data(p7->d.sign->contents)) {
82 ASN1_OCTET_STRING *os; 86 ASN1_OCTET_STRING *os;
@@ -91,7 +95,7 @@ PKCS7_ctrl(PKCS7 *p7, int cmd, long larg, char *parg)
91 break; 95 break;
92 case PKCS7_OP_GET_DETACHED_SIGNATURE: 96 case PKCS7_OP_GET_DETACHED_SIGNATURE:
93 if (nid == NID_pkcs7_signed) { 97 if (nid == NID_pkcs7_signed) {
94 if (!p7->d.sign || !p7->d.sign->contents->d.ptr) 98 if (p7->d.sign || !p7->d.sign->contents->d.ptr)
95 ret = 1; 99 ret = 1;
96 else 100 else
97 ret = 0; 101 ret = 0;