Reapply "[ruby/openssl] x509: disallow ossl_x509{,attr,crl,ext,revoked,name}*_new(NULL)"

This reverts commit ec01cd9bbb.

This should no longer break the tests, now that the following changes
have been applied:

 - RubyGems change: 32977f3869
 - ruby/openssl change: e8261963c7
This commit is contained in:
Kazuki Yamaguchi 2025-07-31 18:45:53 +09:00
parent e8261963c7
commit 0d3d296b85
6 changed files with 18 additions and 42 deletions

View file

@ -54,14 +54,9 @@ ossl_x509attr_new(X509_ATTRIBUTE *attr)
VALUE obj;
obj = NewX509Attr(cX509Attr);
if (!attr) {
new = X509_ATTRIBUTE_new();
} else {
new = X509_ATTRIBUTE_dup(attr);
}
if (!new) {
ossl_raise(eX509AttrError, NULL);
}
new = X509_ATTRIBUTE_dup(attr);
if (!new)
ossl_raise(eX509AttrError, "X509_ATTRIBUTE_dup");
SetX509Attr(obj, new);
return obj;

View file

@ -54,14 +54,9 @@ ossl_x509_new(X509 *x509)
VALUE obj;
obj = NewX509(cX509Cert);
if (!x509) {
new = X509_new();
} else {
new = X509_dup(x509);
}
if (!new) {
ossl_raise(eX509CertError, NULL);
}
new = X509_dup(x509);
if (!new)
ossl_raise(eX509CertError, "X509_dup");
SetX509(obj, new);
return obj;

View file

@ -64,8 +64,9 @@ ossl_x509crl_new(X509_CRL *crl)
VALUE obj;
obj = NewX509CRL(cX509CRL);
tmp = crl ? X509_CRL_dup(crl) : X509_CRL_new();
if(!tmp) ossl_raise(eX509CRLError, NULL);
tmp = X509_CRL_dup(crl);
if (!tmp)
ossl_raise(eX509CRLError, "X509_CRL_dup");
SetX509CRL(obj, tmp);
return obj;

View file

@ -68,14 +68,9 @@ ossl_x509ext_new(X509_EXTENSION *ext)
VALUE obj;
obj = NewX509Ext(cX509Ext);
if (!ext) {
new = X509_EXTENSION_new();
} else {
new = X509_EXTENSION_dup(ext);
}
if (!new) {
ossl_raise(eX509ExtError, NULL);
}
new = X509_EXTENSION_dup(ext);
if (!new)
ossl_raise(eX509ExtError, "X509_EXTENSION_dup");
SetX509Ext(obj, new);
return obj;

View file

@ -59,14 +59,9 @@ ossl_x509name_new(X509_NAME *name)
VALUE obj;
obj = NewX509Name(cX509Name);
if (!name) {
new = X509_NAME_new();
} else {
new = X509_NAME_dup(name);
}
if (!new) {
ossl_raise(eX509NameError, NULL);
}
new = X509_NAME_dup(name);
if (!new)
ossl_raise(eX509NameError, "X509_NAME_dup");
SetX509Name(obj, new);
return obj;

View file

@ -54,14 +54,9 @@ ossl_x509revoked_new(X509_REVOKED *rev)
VALUE obj;
obj = NewX509Rev(cX509Rev);
if (!rev) {
new = X509_REVOKED_new();
} else {
new = X509_REVOKED_dup(rev);
}
if (!new) {
ossl_raise(eX509RevError, NULL);
}
new = X509_REVOKED_dup(rev);
if (!new)
ossl_raise(eX509RevError, "X509_REVOKED_dup");
SetX509Rev(obj, new);
return obj;