hx509: Avoid misleading error message
authorJoseph Sutton <josephsutton@catalyst.net.nz>
Fri, 23 Jun 2023 00:48:51 +0000 (12:48 +1200)
committerAndrew Bartlett <abartlet@samba.org>
Tue, 28 Nov 2023 23:37:39 +0000 (12:37 +1300)
If ‘keyid’ is an empty string, then the numeric error code that gets
appended to this error message may be mistaken for the key ID. Address
this by not mentioning any ID in such cases.

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
lib/hx509/cms.c

index 324220f94378a9814ea7430c8b63a6591be08519..22155d4dbe7eb85af9a82c7bd1a889c69f881a20 100644 (file)
@@ -242,7 +242,10 @@ unparse_CMSIdentifier(hx509_context context,
        if (len < 0)
            return ENOMEM;
 
-       ret = asprintf(str, "certificate with id %s", keyid);
+       if (len)
+           ret = asprintf(str, "certificate with id %s", keyid);
+       else
+           ret = asprintf(str, "certificate");
        free(keyid);
        break;
     }