]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
lib: Use talloc_asprintf_addbufin _ber_read_OID_String_impl
authorVolker Lendecke <vl@samba.org>
Thu, 23 May 2024 14:06:37 +0000 (16:06 +0200)
committerVolker Lendecke <vl@samba.org>
Tue, 4 Jun 2024 07:11:35 +0000 (07:11 +0000)
Just one NULL check required

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
lib/util/asn1.c

index 5376c21cac177c5a2cbe4c005a4e7ee625239edf..52b91b51d0004eaeabbe40b682f236172697332b 100644 (file)
@@ -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;