X-Git-Url: https://git.openssl.org/gitweb/?p=openssl.git;a=blobdiff_plain;f=crypto%2Fobjects%2Fobj_dat.c;h=cbd6e346c188de1ed856f127e1ef8c7259cdecfb;hp=6a068eef436a10e033c184db80cdef2dd97441fe;hb=62d0577e0d5e3703436d0fba362d516481291810;hpb=2b8dc08b74fc3c6d4c2fc855cc23bac691d985be diff --git a/crypto/objects/obj_dat.c b/crypto/objects/obj_dat.c index 6a068eef43..cbd6e346c1 100644 --- a/crypto/objects/obj_dat.c +++ b/crypto/objects/obj_dat.c @@ -59,12 +59,13 @@ #include #include #include -#include "cryptlib.h" +#include "internal/cryptlib.h" #include #include #include #include #include "internal/asn1_int.h" +#include "obj_lcl.h" /* obj_dat.h is generated from objects.h by obj_dat.pl */ #include "obj_dat.h" @@ -78,11 +79,10 @@ DECLARE_OBJ_BSEARCH_CMP_FN(const ASN1_OBJECT *, unsigned int, obj); #define ADDED_LNAME 2 #define ADDED_NID 3 -typedef struct added_obj_st { +struct added_obj_st { int type; ASN1_OBJECT *obj; -} ADDED_OBJ; -DECLARE_LHASH_OF(ADDED_OBJ); +}; static int new_nid = NUM_NID; static LHASH_OF(ADDED_OBJ) *added = NULL; @@ -134,8 +134,6 @@ static unsigned long added_obj_hash(const ADDED_OBJ *ca) return (ret); } -static IMPLEMENT_LHASH_HASH_FN(added_obj, ADDED_OBJ) - static int added_obj_cmp(const ADDED_OBJ *ca, const ADDED_OBJ *cb) { ASN1_OBJECT *a, *b; @@ -174,13 +172,11 @@ static int added_obj_cmp(const ADDED_OBJ *ca, const ADDED_OBJ *cb) } } -static IMPLEMENT_LHASH_COMP_FN(added_obj, ADDED_OBJ) - static int init_added(void) { if (added != NULL) return (1); - added = lh_ADDED_OBJ_new(); + added = lh_ADDED_OBJ_new(added_obj_hash, added_obj_cmp); return (added != NULL); } @@ -227,7 +223,7 @@ void OBJ_cleanup(void) } if (added == NULL) return; - lh_ADDED_OBJ_down_load(added) = 0; + lh_ADDED_OBJ_set_down_load(added, 0); lh_ADDED_OBJ_doall(added, LHASH_DOALL_FN(cleanup1)); /* zero counters */ lh_ADDED_OBJ_doall(added, LHASH_DOALL_FN(cleanup2)); /* set counters */ lh_ADDED_OBJ_doall(added, LHASH_DOALL_FN(cleanup3)); /* free objects */ @@ -397,6 +393,9 @@ int OBJ_obj2nid(const ASN1_OBJECT *a) if (a->nid != 0) return (a->nid); + if (a->length == 0) + return NID_undef; + if (added != NULL) { ad.type = ADDED_DATA; ad.obj = (ASN1_OBJECT *)a; /* XXX: ugly but harmless */ @@ -481,7 +480,7 @@ int OBJ_obj2txt(char *buf, int buf_len, const ASN1_OBJECT *a, int no_name) s = OBJ_nid2sn(nid); if (s) { if (buf) - BUF_strlcpy(buf, s, buf_len); + OPENSSL_strlcpy(buf, s, buf_len); n = strlen(s); return n; } @@ -555,7 +554,7 @@ int OBJ_obj2txt(char *buf, int buf_len, const ASN1_OBJECT *a, int no_name) *buf = '\0'; buf_len--; } - BUF_strlcpy(buf, bndec, buf_len); + OPENSSL_strlcpy(buf, bndec, buf_len); if (i > buf_len) { buf += buf_len; buf_len = 0; @@ -571,7 +570,7 @@ int OBJ_obj2txt(char *buf, int buf_len, const ASN1_OBJECT *a, int no_name) BIO_snprintf(tbuf, sizeof tbuf, ".%lu", l); i = strlen(tbuf); if (buf && (buf_len > 0)) { - BUF_strlcpy(buf, tbuf, buf_len); + OPENSSL_strlcpy(buf, tbuf, buf_len); if (i > buf_len) { buf += buf_len; buf_len = 0;