[前][次][番号順一覧][スレッド一覧]

ruby-changes:65535

From: Kazuki <ko1@a...>
Date: Tue, 16 Mar 2021 20:39:17 +0900 (JST)
Subject: [ruby-changes:65535] 871c61d5d0 (master): [ruby/openssl] x509stoRe: avoid ossl_raise() calls with NULL message

https://git.ruby-lang.org/ruby.git/commit/?id=871c61d5d0

From 871c61d5d068f85595c04b8d118da1f489bc2d42 Mon Sep 17 00:00:00 2001
From: Kazuki Yamaguchi <k@r...>
Date: Sun, 9 Aug 2020 00:04:56 +0900
Subject: [ruby/openssl] x509store: avoid ossl_raise() calls with NULL message

Use the OpenSSL function name that caused the error to generate a better
error message.

https://github.com/ruby/openssl/commit/b31809ba3d
---
 ext/openssl/ossl_x509store.c | 33 ++++++++++++++-------------------
 1 file changed, 14 insertions(+), 19 deletions(-)

diff --git a/ext/openssl/ossl_x509store.c b/ext/openssl/ossl_x509store.c
index 5968148..6554d63 100644
--- a/ext/openssl/ossl_x509store.c
+++ b/ext/openssl/ossl_x509store.c
@@ -157,9 +157,8 @@ ossl_x509store_alloc(VALUE klass) https://github.com/ruby/ruby/blob/trunk/ext/openssl/ossl_x509store.c#L157
     VALUE obj;
 
     obj = NewX509Store(klass);
-    if((store = X509_STORE_new()) == NULL){
-        ossl_raise(eX509StoreError, NULL);
-    }
+    if ((store = X509_STORE_new()) == NULL)
+        ossl_raise(eX509StoreError, "X509_STORE_new");
     SetX509Store(obj, store);
 
     return obj;
@@ -365,9 +364,8 @@ ossl_x509store_set_default_paths(VALUE self) https://github.com/ruby/ruby/blob/trunk/ext/openssl/ossl_x509store.c#L364
     X509_STORE *store;
 
     GetX509Store(self, store);
-    if (X509_STORE_set_default_paths(store) != 1){
-        ossl_raise(eX509StoreError, NULL);
-    }
+    if (X509_STORE_set_default_paths(store) != 1)
+        ossl_raise(eX509StoreError, "X509_STORE_set_default_paths");
 
     return Qnil;
 }
@@ -386,9 +384,8 @@ ossl_x509store_add_cert(VALUE self, VALUE arg) https://github.com/ruby/ruby/blob/trunk/ext/openssl/ossl_x509store.c#L384
 
     cert = GetX509CertPtr(arg); /* NO NEED TO DUP */
     GetX509Store(self, store);
-    if (X509_STORE_add_cert(store, cert) != 1){
-        ossl_raise(eX509StoreError, NULL);
-    }
+    if (X509_STORE_add_cert(store, cert) != 1)
+        ossl_raise(eX509StoreError, "X509_STORE_add_cert");
 
     return self;
 }
@@ -407,9 +404,8 @@ ossl_x509store_add_crl(VALUE self, VALUE arg) https://github.com/ruby/ruby/blob/trunk/ext/openssl/ossl_x509store.c#L404
 
     crl = GetX509CRLPtr(arg); /* NO NEED TO DUP */
     GetX509Store(self, store);
-    if (X509_STORE_add_crl(store, crl) != 1){
-        ossl_raise(eX509StoreError, NULL);
-    }
+    if (X509_STORE_add_crl(store, crl) != 1)
+        ossl_raise(eX509StoreError, "X509_STORE_add_crl");
 
     return self;
 }
@@ -488,9 +484,8 @@ ossl_x509stctx_alloc(VALUE klass) https://github.com/ruby/ruby/blob/trunk/ext/openssl/ossl_x509store.c#L484
     VALUE obj;
 
     obj = NewX509StCtx(klass);
-    if((ctx = X509_STORE_CTX_new()) == NULL){
-        ossl_raise(eX509StoreError, NULL);
-    }
+    if ((ctx = X509_STORE_CTX_new()) == NULL)
+        ossl_raise(eX509StoreError, "X509_STORE_CTX_new");
     SetX509StCtx(obj, ctx);
 
     return obj;
@@ -557,12 +552,12 @@ ossl_x509stctx_verify(VALUE self) https://github.com/ruby/ruby/blob/trunk/ext/openssl/ossl_x509store.c#L552
 
     switch (X509_verify_cert(ctx)) {
       case 1:
-	return Qtrue;
+        return Qtrue;
       case 0:
-	ossl_clear_error();
-	return Qfalse;
+        ossl_clear_error();
+        return Qfalse;
       default:
-	ossl_raise(eX509CertError, NULL);
+        ossl_raise(eX509CertError, "X509_verify_cert");
     }
 }
 
-- 
cgit v1.1


--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]