diff options
author | Theo Buehler <tb@cvs.openbsd.org> | 2023-05-23 11:51:13 +0000 |
---|---|---|
committer | Theo Buehler <tb@cvs.openbsd.org> | 2023-05-23 11:51:13 +0000 |
commit | 277d7f9c7d36ebd92f2dd992ee24b964a73620dc (patch) | |
tree | 66f71ea9dad1f0cd9bafd4e5d3be5543a7fd6ab8 | |
parent | c25c99554a014ebc517257192d1e7c120236993f (diff) |
Simplify OBJ_obj2txt()
Instead of adding a NUL termination to OBJ_obj2txt(), move the aobj == NULL
or aobj->data == NULL checks to i2t_ASN1_OBJECT_internal(). The only other
caller, i2t_ASN1_OBJECT(), fails on aobj == NULL and aobj->length == 0, and
the latter condition is implied by aobj->data.
Cleaner solution for obj_dat.c r1.52
suggested by/ok jsing
-rw-r--r-- | lib/libcrypto/asn1/a_object.c | 5 | ||||
-rw-r--r-- | lib/libcrypto/objects/obj_dat.c | 8 |
2 files changed, 5 insertions, 8 deletions
diff --git a/lib/libcrypto/asn1/a_object.c b/lib/libcrypto/asn1/a_object.c index 8c8ca8537fb..af19858f74f 100644 --- a/lib/libcrypto/asn1/a_object.c +++ b/lib/libcrypto/asn1/a_object.c @@ -1,4 +1,4 @@ -/* $OpenBSD: a_object.c,v 1.49 2022/11/26 16:08:50 tb Exp $ */ +/* $OpenBSD: a_object.c,v 1.50 2023/05/23 11:51:12 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -433,6 +433,9 @@ i2t_ASN1_OBJECT_internal(const ASN1_OBJECT *aobj, char *buf, int buf_len, int no if (buf_len > 0) buf[0] = '\0'; + if (aobj == NULL || aobj->data == NULL) + return 0; + if (!CBB_init(&cbb, 0)) goto err; if (!i2t_ASN1_OBJECT_cbb(aobj, &cbb, no_name)) diff --git a/lib/libcrypto/objects/obj_dat.c b/lib/libcrypto/objects/obj_dat.c index fcc21ddfb42..7516a6d09a7 100644 --- a/lib/libcrypto/objects/obj_dat.c +++ b/lib/libcrypto/objects/obj_dat.c @@ -1,4 +1,4 @@ -/* $OpenBSD: obj_dat.c,v 1.52 2023/05/23 11:04:04 tb Exp $ */ +/* $OpenBSD: obj_dat.c,v 1.53 2023/05/23 11:51:12 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -499,12 +499,6 @@ OBJ_txt2obj(const char *s, int no_name) int OBJ_obj2txt(char *buf, int buf_len, const ASN1_OBJECT *aobj, int no_name) { - if (buf_len > 0) - buf[0] = '\0'; - - if (aobj == NULL || aobj->data == NULL) - return 0; - return i2t_ASN1_OBJECT_internal(aobj, buf, buf_len, no_name); } |