Steve,
> I see. Well that is probably best fixed within X509_REQ_add_extensions()
> itself by checking to see if the field is NULL and allocating it if
> necessary.
Here's a patch. While looking at the code, I've also checked the other
functions in x509_req.c. They all seem to either allocate the stack if
needed or fail gracefully otherwise.
Thanks, Remo
diff -ru openssl-0.9.8b/crypto/x509/x509_req.c
openssl-0.9.8b-custom/crypto/x509/x509_req.c
--- openssl-0.9.8b/crypto/x509/x509_req.c 2004-09-10 22:20:54.000000000
+0200
+++ openssl-0.9.8b-custom/crypto/x509/x509_req.c 2006-06-02
16:54:19.000000000 +0200
@@ -242,6 +242,11 @@
at = NULL;
attr->single = 0;
attr->object = OBJ_nid2obj(nid);
+ if(!req->req_info->attributes)
+ {
+ if(!(req->req_info->attributes = sk_X509_ATTRIBUTE_new_null()))
+ goto err;
+ }
if(!sk_X509_ATTRIBUTE_push(req->req_info->attributes, attr)) goto err;
return 1;
err: