From 0321f31a8e1364b32fad61e99856024eaed0b81e Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Thu, 23 May 2024 16:06:37 +0200 Subject: [PATCH] lib: Use talloc_asprintf_addbufin _ber_read_OID_String_impl Just one NULL check required Signed-off-by: Volker Lendecke Reviewed-by: Andrew Bartlett --- lib/util/asn1.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/util/asn1.c b/lib/util/asn1.c index 5376c21cac1..52b91b51d00 100644 --- a/lib/util/asn1.c +++ b/lib/util/asn1.c @@ -778,7 +778,6 @@ static bool _ber_read_OID_String_impl(TALLOC_CTX *mem_ctx, DATA_BLOB blob, b = blob.data; tmp_oid = talloc_asprintf(mem_ctx, "%u.%u", b[0]/40, b[0]%40); - if (!tmp_oid) goto nomem; if (bytes_eaten != NULL) { *bytes_eaten = 0; @@ -787,12 +786,15 @@ static bool _ber_read_OID_String_impl(TALLOC_CTX *mem_ctx, DATA_BLOB blob, for(i = 1, v = 0; i < blob.length; i++) { v = (v<<7) | (b[i]&0x7f); if ( ! (b[i] & 0x80)) { - tmp_oid = talloc_asprintf_append_buffer(tmp_oid, ".%u", v); + talloc_asprintf_addbuf(&tmp_oid, ".%u", v); v = 0; if (bytes_eaten) *bytes_eaten = i+1; } - if (!tmp_oid) goto nomem; + } + + if (tmp_oid == NULL) { + goto nomem; } *OID = tmp_oid; -- 2.47.3