From 59f89e4b15cd603a1ef7165a8dce89899eed4486 Mon Sep 17 00:00:00 2001 From: Joseph Sutton Date: Fri, 23 Jun 2023 12:48:51 +1200 Subject: [PATCH] hx509: Avoid misleading error message MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- lib/hx509/cms.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/hx509/cms.c b/lib/hx509/cms.c index 37c437788..af3dd47aa 100644 --- a/lib/hx509/cms.c +++ b/lib/hx509/cms.c @@ -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; }