diff options
Diffstat (limited to 'deps/openssl/openssl/crypto/asn1/asn_moid.c')
-rw-r--r-- | deps/openssl/openssl/crypto/asn1/asn_moid.c | 45 |
1 files changed, 20 insertions, 25 deletions
diff --git a/deps/openssl/openssl/crypto/asn1/asn_moid.c b/deps/openssl/openssl/crypto/asn1/asn_moid.c index 8176b76008..68a01f3117 100644 --- a/deps/openssl/openssl/crypto/asn1/asn_moid.c +++ b/deps/openssl/openssl/crypto/asn1/asn_moid.c @@ -1,5 +1,5 @@ /* - * Copyright 2002-2016 The OpenSSL Project Authors. All Rights Reserved. + * Copyright 2002-2018 The OpenSSL Project Authors. All Rights Reserved. * * Licensed under the OpenSSL license (the "License"). You may not use * this file except in compliance with the License. You can obtain a copy @@ -8,7 +8,7 @@ */ #include <stdio.h> -#include <ctype.h> +#include "internal/ctype.h" #include <openssl/crypto.h> #include "internal/cryptlib.h" #include <openssl/conf.h> @@ -60,46 +60,41 @@ 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 (isspace((unsigned char)*ostr)) + while (ossl_isspace(*ostr)) ostr++; - } - - nid = OBJ_create(ostr, name, ln); - - if (nid == NID_undef) - return 0; - - if (p) { - ln = value; - while (isspace((unsigned char)*ln)) + while (ossl_isspace(*ln)) ln++; p--; - while (isspace((unsigned char)*p)) { + while (ossl_isspace(*p)) { if (p == ln) return 0; p--; } p++; - lntmp = OPENSSL_malloc((p - ln) + 1); - if (lntmp == NULL) + if ((lntmp = OPENSSL_malloc((p - ln) + 1)) == NULL) { + ASN1err(ASN1_F_DO_CREATE, ERR_R_MALLOC_FAILURE); 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; } |