summaryrefslogtreecommitdiff
path: root/lib/libcrypto/ts/ts_lib.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/libcrypto/ts/ts_lib.c')
-rw-r--r--lib/libcrypto/ts/ts_lib.c33
1 files changed, 19 insertions, 14 deletions
diff --git a/lib/libcrypto/ts/ts_lib.c b/lib/libcrypto/ts/ts_lib.c
index 1e94922aa19..7e401017529 100644
--- a/lib/libcrypto/ts/ts_lib.c
+++ b/lib/libcrypto/ts/ts_lib.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ts_lib.c,v 1.14 2023/07/07 07:25:21 beck Exp $ */
+/* $OpenBSD: ts_lib.c,v 1.15 2025/01/07 14:22:19 tb Exp $ */
/* Written by Zoltan Glozik (zglozik@stones.com) for the OpenSSL
* project 2002.
*/
@@ -74,20 +74,25 @@
int
TS_ASN1_INTEGER_print_bio(BIO *bio, const ASN1_INTEGER *num)
{
- BIGNUM num_bn;
- int result = 0;
- char *hex;
-
- BN_init(&num_bn);
- ASN1_INTEGER_to_BN(num, &num_bn);
- if ((hex = BN_bn2hex(&num_bn))) {
- result = BIO_write(bio, "0x", 2) > 0;
- result = result && BIO_write(bio, hex, strlen(hex)) > 0;
- free(hex);
- }
- BN_free(&num_bn);
+ BIGNUM *bn = NULL;
+ char *hex = NULL;
+ int ret = 0;
+
+ /* XXX - OpenSSL decided to return -1 here for some stupid reason. */
+ if ((bn = ASN1_INTEGER_to_BN(num, NULL)) == NULL)
+ goto err;
+ if ((hex = BN_bn2hex(bn)) == NULL)
+ goto err;
+ if (BIO_printf(bio, "0x%s", hex) <= 0)
+ goto err;
+
+ ret = 1;
+
+ err:
+ BN_free(bn);
+ free(hex);
- return result;
+ return ret;
}
LCRYPTO_ALIAS(TS_ASN1_INTEGER_print_bio);