[openssl-commits] [openssl] master update

Andy Polyakov appro at openssl.org
Wed Aug 22 19:38:01 UTC 2018


The branch master has been updated
       via  2d162ea93f6512909454ee10597b63206862a056 (commit)
       via  19934970ac8534cd19eb3f64299e5731d97a7a80 (commit)
      from  f112dc82a44729d3f7c853c01047f6bfeb8f90ce (commit)


- Log -----------------------------------------------------------------
commit 2d162ea93f6512909454ee10597b63206862a056
Author: Andy Polyakov <appro at openssl.org>
Date:   Mon Aug 20 09:38:36 2018 +0200

    man3/OBJ_nid2obj.pod: mention failure code for OBJ_create.
    
    Reviewed-by: Kurt Roeckx <kurt at roeckx.be>
    Reviewed-by: Richard Levitte <levitte at openssl.org>
    (Merged from https://github.com/openssl/openssl/pull/6998)

commit 19934970ac8534cd19eb3f64299e5731d97a7a80
Author: Andy Polyakov <appro at openssl.org>
Date:   Fri Aug 17 23:04:03 2018 +0200

    asn1/asn_moid.c: overhaul do_create.
    
    Original could allocate nid and then bail out on malloc failure. Instead
    allocate first *then* attempt to create object.
    
    Reviewed-by: Kurt Roeckx <kurt at roeckx.be>
    Reviewed-by: Richard Levitte <levitte at openssl.org>
    (Merged from https://github.com/openssl/openssl/pull/6998)

-----------------------------------------------------------------------

Summary of changes:
 crypto/asn1/asn_moid.c   | 30 ++++++++++++------------------
 doc/man3/OBJ_nid2obj.pod |  3 ++-
 2 files changed, 14 insertions(+), 19 deletions(-)

diff --git a/crypto/asn1/asn_moid.c b/crypto/asn1/asn_moid.c
index f0b4dab..68a01f3 100644
--- a/crypto/asn1/asn_moid.c
+++ b/crypto/asn1/asn_moid.c
@@ -60,29 +60,20 @@ void ASN1_add_oid_module(void)
 static int do_create(const char *value, const char *name)
 {
     int nid;
-    ASN1_OBJECT *oid;
     const char *ln, *ostr, *p;
-    char *lntmp;
+    char *lntmp = NULL;
+
     p = strrchr(value, ',');
-    if (!p) {
+    if (p == NULL) {
         ln = name;
         ostr = value;
     } else {
-        ln = NULL;
+        ln = value;
         ostr = p + 1;
-        if (!*ostr)
+        if (*ostr == '\0')
             return 0;
         while (ossl_isspace(*ostr))
             ostr++;
-    }
-
-    nid = OBJ_create(ostr, name, ln);
-
-    if (nid == NID_undef)
-        return 0;
-
-    if (p) {
-        ln = value;
         while (ossl_isspace(*ln))
             ln++;
         p--;
@@ -97,10 +88,13 @@ static int do_create(const char *value, const char *name)
             return 0;
         }
         memcpy(lntmp, ln, p - ln);
-        lntmp[p - ln] = 0;
-        oid = OBJ_nid2obj(nid);
-        oid->ln = lntmp;
+        lntmp[p - ln] = '\0';
+        ln = lntmp;
     }
 
-    return 1;
+    nid = OBJ_create(ostr, name, ln);
+
+    OPENSSL_free(lntmp);
+
+    return nid != NID_undef;
 }
diff --git a/doc/man3/OBJ_nid2obj.pod b/doc/man3/OBJ_nid2obj.pod
index df4e2e1..cbf889f 100644
--- a/doc/man3/OBJ_nid2obj.pod
+++ b/doc/man3/OBJ_nid2obj.pod
@@ -84,7 +84,8 @@ OBJ_dup() returns a copy of B<o>.
 
 OBJ_create() adds a new object to the internal table. B<oid> is the
 numerical form of the object, B<sn> the short name and B<ln> the
-long name. A new NID is returned for the created object.
+long name. A new NID is returned for the created object in case of
+success and NID_undef in case of failure.
 
 OBJ_length() returns the size of the content octets of B<obj>.
 


More information about the openssl-commits mailing list