diff options
Diffstat (limited to 'src/lib/libcrypto/x509/x509_att.c')
-rw-r--r-- | src/lib/libcrypto/x509/x509_att.c | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/src/lib/libcrypto/x509/x509_att.c b/src/lib/libcrypto/x509/x509_att.c index 511b49d589..98460e8921 100644 --- a/src/lib/libcrypto/x509/x509_att.c +++ b/src/lib/libcrypto/x509/x509_att.c | |||
@@ -245,7 +245,7 @@ X509_ATTRIBUTE *X509_ATTRIBUTE_create_by_OBJ(X509_ATTRIBUTE **attr, | |||
245 | goto err; | 245 | goto err; |
246 | if (!X509_ATTRIBUTE_set1_data(ret,atrtype,data,len)) | 246 | if (!X509_ATTRIBUTE_set1_data(ret,atrtype,data,len)) |
247 | goto err; | 247 | goto err; |
248 | 248 | ||
249 | if ((attr != NULL) && (*attr == NULL)) *attr=ret; | 249 | if ((attr != NULL) && (*attr == NULL)) *attr=ret; |
250 | return(ret); | 250 | return(ret); |
251 | err: | 251 | err: |
@@ -302,8 +302,15 @@ int X509_ATTRIBUTE_set1_data(X509_ATTRIBUTE *attr, int attrtype, const void *dat | |||
302 | atype = attrtype; | 302 | atype = attrtype; |
303 | } | 303 | } |
304 | if(!(attr->value.set = sk_ASN1_TYPE_new_null())) goto err; | 304 | if(!(attr->value.set = sk_ASN1_TYPE_new_null())) goto err; |
305 | attr->single = 0; | ||
306 | /* This is a bit naughty because the attribute should really have | ||
307 | * at least one value but some types use and zero length SET and | ||
308 | * require this. | ||
309 | */ | ||
310 | if (attrtype == 0) | ||
311 | return 1; | ||
305 | if(!(ttmp = ASN1_TYPE_new())) goto err; | 312 | if(!(ttmp = ASN1_TYPE_new())) goto err; |
306 | if (len == -1) | 313 | if ((len == -1) && !(attrtype & MBSTRING_FLAG)) |
307 | { | 314 | { |
308 | if (!ASN1_TYPE_set1(ttmp, attrtype, data)) | 315 | if (!ASN1_TYPE_set1(ttmp, attrtype, data)) |
309 | goto err; | 316 | goto err; |
@@ -311,7 +318,6 @@ int X509_ATTRIBUTE_set1_data(X509_ATTRIBUTE *attr, int attrtype, const void *dat | |||
311 | else | 318 | else |
312 | ASN1_TYPE_set(ttmp, atype, stmp); | 319 | ASN1_TYPE_set(ttmp, atype, stmp); |
313 | if(!sk_ASN1_TYPE_push(attr->value.set, ttmp)) goto err; | 320 | if(!sk_ASN1_TYPE_push(attr->value.set, ttmp)) goto err; |
314 | attr->single = 0; | ||
315 | return 1; | 321 | return 1; |
316 | err: | 322 | err: |
317 | X509err(X509_F_X509_ATTRIBUTE_SET1_DATA, ERR_R_MALLOC_FAILURE); | 323 | X509err(X509_F_X509_ATTRIBUTE_SET1_DATA, ERR_R_MALLOC_FAILURE); |