Correct misleading diagnostics of OBJ_txt2obj on unknown object name
authorDr. David von Oheimb <David.von.Oheimb@siemens.com>
Fri, 26 Jun 2020 14:16:56 +0000 (16:16 +0200)
committerDr. David von Oheimb <David.von.Oheimb@siemens.com>
Tue, 4 Aug 2020 07:17:47 +0000 (09:17 +0200)
Reviewed-by: Paul Dale <paul.dale@oracle.com>
(Merged from https://github.com/openssl/openssl/pull/12296)

crypto/err/openssl.txt
crypto/objects/obj_dat.c
crypto/objects/obj_err.c
include/openssl/objectserr.h

index 1b4fca9b970fc5385ad2deb0e1ac8c7d91b3c8dc..1fa0df36b12237ce2a9ead469275e30f3e463945 100644 (file)
@@ -2668,6 +2668,7 @@ KDF_R_VALUE_MISSING:102:value missing
 KDF_R_WRONG_OUTPUT_BUFFER_SIZE:112:wrong output buffer size
 OBJ_R_OID_EXISTS:102:oid exists
 OBJ_R_UNKNOWN_NID:101:unknown nid
+OBJ_R_UNKNOWN_OBJECT_NAME:103:unknown object name
 OCSP_R_CERTIFICATE_VERIFY_ERROR:101:certificate verify error
 OCSP_R_DIGEST_ERR:102:digest err
 OCSP_R_ERROR_IN_NEXTUPDATE_FIELD:122:error in nextupdate field
index 0c4ec985cb2c9f4d14625f4e854ae0b266986dc7..b2fd4a022638e7f913d98615438feec90ca0ff7f 100644 (file)
@@ -372,6 +372,10 @@ ASN1_OBJECT *OBJ_txt2obj(const char *s, int no_name)
         if (((nid = OBJ_sn2nid(s)) != NID_undef) ||
             ((nid = OBJ_ln2nid(s)) != NID_undef))
             return OBJ_nid2obj(nid);
+        if (!ossl_isdigit(*s)) {
+            OBJerr(OBJ_F_OBJ_TXT2OBJ, OBJ_R_UNKNOWN_OBJECT_NAME);
+            return NULL;
+        }
     }
 
     /* Work out size of content octets */
index b32e9f6f55ea51a48d90d6248acb32d4fda666c6..c55e8ef2d0b91f5b727b0349e4c8f610257fac6a 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * Generated by util/mkerr.pl DO NOT EDIT
- * Copyright 1995-2019 The OpenSSL Project Authors. All Rights Reserved.
+ * Copyright 1995-2020 The OpenSSL Project Authors. All Rights Reserved.
  *
  * Licensed under the Apache License 2.0 (the "License").  You may not use
  * this file except in compliance with the License.  You can obtain a copy
@@ -16,6 +16,8 @@
 static const ERR_STRING_DATA OBJ_str_reasons[] = {
     {ERR_PACK(ERR_LIB_OBJ, 0, OBJ_R_OID_EXISTS), "oid exists"},
     {ERR_PACK(ERR_LIB_OBJ, 0, OBJ_R_UNKNOWN_NID), "unknown nid"},
+    {ERR_PACK(ERR_LIB_OBJ, 0, OBJ_R_UNKNOWN_OBJECT_NAME),
+    "unknown object name"},
     {0, NULL}
 };
 
index 3cac9a7327cb087124c895ea3029dd76a64ac06e..f1de77945b1fb62232e5074c644419d7b0ae18e2 100644 (file)
@@ -8,8 +8,8 @@
  * https://www.openssl.org/source/license.html
  */
 
-#ifndef OPENSSL_OBJECTSERR_H
-# define OPENSSL_OBJECTSERR_H
+#ifndef OPENSSL_OBJERR_H
+# define OPENSSL_OBJERR_H
 # pragma once
 
 # include <openssl/opensslconf.h>
@@ -41,5 +41,6 @@ int ERR_load_OBJ_strings(void);
  */
 # define OBJ_R_OID_EXISTS                                 102
 # define OBJ_R_UNKNOWN_NID                                101
+# define OBJ_R_UNKNOWN_OBJECT_NAME                        103
 
 #endif