summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto/x509/x509_att.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/libcrypto/x509/x509_att.c')
-rw-r--r--src/lib/libcrypto/x509/x509_att.c27
1 files changed, 10 insertions, 17 deletions
diff --git a/src/lib/libcrypto/x509/x509_att.c b/src/lib/libcrypto/x509/x509_att.c
index 38aa063143..8d369df900 100644
--- a/src/lib/libcrypto/x509/x509_att.c
+++ b/src/lib/libcrypto/x509/x509_att.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: x509_att.c,v 1.18 2021/11/01 20:53:08 tb Exp $ */ 1/* $OpenBSD: x509_att.c,v 1.19 2022/05/09 19:19:33 jsing 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 *
@@ -324,10 +324,8 @@ X509_ATTRIBUTE_set1_data(X509_ATTRIBUTE *attr, int attrtype, const void *data,
324 goto err; 324 goto err;
325 atype = attrtype; 325 atype = attrtype;
326 } 326 }
327 if (!(attr->value.set = sk_ASN1_TYPE_new_null())) 327 /*
328 goto err; 328 * This is a bit naughty because the attribute should really have
329 attr->single = 0;
330 /* This is a bit naughty because the attribute should really have
331 * at least one value but some types use and zero length SET and 329 * at least one value but some types use and zero length SET and
332 * require this. 330 * require this.
333 */ 331 */
@@ -343,7 +341,7 @@ X509_ATTRIBUTE_set1_data(X509_ATTRIBUTE *attr, int attrtype, const void *data,
343 goto err; 341 goto err;
344 } else 342 } else
345 ASN1_TYPE_set(ttmp, atype, stmp); 343 ASN1_TYPE_set(ttmp, atype, stmp);
346 if (!sk_ASN1_TYPE_push(attr->value.set, ttmp)) 344 if (!sk_ASN1_TYPE_push(attr->set, ttmp))
347 goto err; 345 goto err;
348 return 1; 346 return 1;
349 347
@@ -357,11 +355,10 @@ err:
357int 355int
358X509_ATTRIBUTE_count(const X509_ATTRIBUTE *attr) 356X509_ATTRIBUTE_count(const X509_ATTRIBUTE *attr)
359{ 357{
360 if (!attr->single) 358 if (attr == NULL)
361 return sk_ASN1_TYPE_num(attr->value.set); 359 return 0;
362 if (attr->value.single) 360
363 return 1; 361 return sk_ASN1_TYPE_num(attr->set);
364 return 0;
365} 362}
366 363
367ASN1_OBJECT * 364ASN1_OBJECT *
@@ -392,10 +389,6 @@ X509_ATTRIBUTE_get0_type(X509_ATTRIBUTE *attr, int idx)
392{ 389{
393 if (attr == NULL) 390 if (attr == NULL)
394 return (NULL); 391 return (NULL);
395 if (idx >= X509_ATTRIBUTE_count(attr)) 392
396 return NULL; 393 return sk_ASN1_TYPE_value(attr->set, idx);
397 if (!attr->single)
398 return sk_ASN1_TYPE_value(attr->value.set, idx);
399 else
400 return attr->value.single;
401} 394}