projects
/
oweals
/
openssl.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
sha[1|512]-armv8.pl: get instruction endianness right.
[oweals/openssl.git]
/
crypto
/
x509
/
x509_att.c
diff --git
a/crypto/x509/x509_att.c
b/crypto/x509/x509_att.c
index 9245bfd9f5d2a04f34fa9a4e22ee361f584fa04f..98460e8921534150003e4a9d7a1e933a10220cd5 100644
(file)
--- a/
crypto/x509/x509_att.c
+++ b/
crypto/x509/x509_att.c
@@
-67,8
+67,7
@@
int X509at_get_attr_count(const STACK_OF(X509_ATTRIBUTE) *x)
{
int X509at_get_attr_count(const STACK_OF(X509_ATTRIBUTE) *x)
{
- if (!x) return 0;
- return(sk_X509_ATTRIBUTE_num(x));
+ return sk_X509_ATTRIBUTE_num(x);
}
int X509at_get_attr_by_NID(const STACK_OF(X509_ATTRIBUTE) *x, int nid,
}
int X509at_get_attr_by_NID(const STACK_OF(X509_ATTRIBUTE) *x, int nid,
@@
-206,7
+205,7
@@
void *X509at_get0_data_by_OBJ(STACK_OF(X509_ATTRIBUTE) *x,
at = X509at_get_attr(x, i);
if (lastpos <= -3 && (X509_ATTRIBUTE_count(at) != 1))
return NULL;
at = X509at_get_attr(x, i);
if (lastpos <= -3 && (X509_ATTRIBUTE_count(at) != 1))
return NULL;
- return X509_ATTRIBUTE_get0_data(at,
type, 0
, NULL);
+ return X509_ATTRIBUTE_get0_data(at,
0, type
, NULL);
}
X509_ATTRIBUTE *X509_ATTRIBUTE_create_by_NID(X509_ATTRIBUTE **attr, int nid,
}
X509_ATTRIBUTE *X509_ATTRIBUTE_create_by_NID(X509_ATTRIBUTE **attr, int nid,
@@
-246,7
+245,7
@@
X509_ATTRIBUTE *X509_ATTRIBUTE_create_by_OBJ(X509_ATTRIBUTE **attr,
goto err;
if (!X509_ATTRIBUTE_set1_data(ret,atrtype,data,len))
goto err;
goto err;
if (!X509_ATTRIBUTE_set1_data(ret,atrtype,data,len))
goto err;
-
+
if ((attr != NULL) && (*attr == NULL)) *attr=ret;
return(ret);
err:
if ((attr != NULL) && (*attr == NULL)) *attr=ret;
return(ret);
err:
@@
-286,8
+285,8
@@
int X509_ATTRIBUTE_set1_object(X509_ATTRIBUTE *attr, const ASN1_OBJECT *obj)
int X509_ATTRIBUTE_set1_data(X509_ATTRIBUTE *attr, int attrtype, const void *data, int len)
{
ASN1_TYPE *ttmp;
int X509_ATTRIBUTE_set1_data(X509_ATTRIBUTE *attr, int attrtype, const void *data, int len)
{
ASN1_TYPE *ttmp;
- ASN1_STRING *stmp;
- int atype;
+ ASN1_STRING *stmp
= NULL
;
+ int atype
= 0
;
if (!attr) return 0;
if(attrtype & MBSTRING_FLAG) {
stmp = ASN1_STRING_set_by_NID(NULL, data, len, attrtype,
if (!attr) return 0;
if(attrtype & MBSTRING_FLAG) {
stmp = ASN1_STRING_set_by_NID(NULL, data, len, attrtype,
@@
-303,8
+302,15
@@
int X509_ATTRIBUTE_set1_data(X509_ATTRIBUTE *attr, int attrtype, const void *dat
atype = attrtype;
}
if(!(attr->value.set = sk_ASN1_TYPE_new_null())) goto err;
atype = attrtype;
}
if(!(attr->value.set = sk_ASN1_TYPE_new_null())) goto err;
+ attr->single = 0;
+ /* This is a bit naughty because the attribute should really have
+ * at least one value but some types use and zero length SET and
+ * require this.
+ */
+ if (attrtype == 0)
+ return 1;
if(!(ttmp = ASN1_TYPE_new())) goto err;
if(!(ttmp = ASN1_TYPE_new())) goto err;
- if (
len == -1
)
+ if (
(len == -1) && !(attrtype & MBSTRING_FLAG)
)
{
if (!ASN1_TYPE_set1(ttmp, attrtype, data))
goto err;
{
if (!ASN1_TYPE_set1(ttmp, attrtype, data))
goto err;
@@
-312,7
+318,6
@@
int X509_ATTRIBUTE_set1_data(X509_ATTRIBUTE *attr, int attrtype, const void *dat
else
ASN1_TYPE_set(ttmp, atype, stmp);
if(!sk_ASN1_TYPE_push(attr->value.set, ttmp)) goto err;
else
ASN1_TYPE_set(ttmp, atype, stmp);
if(!sk_ASN1_TYPE_push(attr->value.set, ttmp)) goto err;
- attr->single = 0;
return 1;
err:
X509err(X509_F_X509_ATTRIBUTE_SET1_DATA, ERR_R_MALLOC_FAILURE);
return 1;
err:
X509err(X509_F_X509_ATTRIBUTE_SET1_DATA, ERR_R_MALLOC_FAILURE);