From 7cab7499f764c06376e465d4c8264bd7315c181c Mon Sep 17 00:00:00 2001 From: tb <> Date: Tue, 23 May 2023 11:51:12 +0000 Subject: 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 --- src/lib/libcrypto/asn1/a_object.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'src/lib/libcrypto/asn1/a_object.c') diff --git a/src/lib/libcrypto/asn1/a_object.c b/src/lib/libcrypto/asn1/a_object.c index 8c8ca8537f..af19858f74 100644 --- a/src/lib/libcrypto/asn1/a_object.c +++ b/src/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)) -- cgit v1.2.3-55-g6feb