summaryrefslogtreecommitdiffstats
path: root/apps/openssl.c
diff options
context:
space:
mode:
authorPauli <paul.dale@oracle.com>2019-06-20 11:24:17 +1000
committerPauli <paul.dale@oracle.com>2019-06-21 08:29:44 +1000
commit2d905f6715453034d1f942a0237b0d2b9d57326c (patch)
tree5d658a96ab4a8dce668a4b925a3120317ecf2b41 /apps/openssl.c
parentba4341316ce762f917f973bb4ac604062fb11724 (diff)
Print thread IDs nicely.
Remove the union that effectively cast thread IDs to long integers before display and instead print a hex dump of the entire object. Refer #9191 Reviewed-by: Richard Levitte <levitte@openssl.org> (Merged from https://github.com/openssl/openssl/pull/9194)
Diffstat (limited to 'apps/openssl.c')
-rw-r--r--apps/openssl.c19
1 files changed, 8 insertions, 11 deletions
diff --git a/apps/openssl.c b/apps/openssl.c
index 7a490cc455..d6820a191e 100644
--- a/apps/openssl.c
+++ b/apps/openssl.c
@@ -1,5 +1,5 @@
/*
- * Copyright 1995-2018 The OpenSSL Project Authors. All Rights Reserved.
+ * Copyright 1995-2019 The OpenSSL Project Authors. All Rights Reserved.
*
* Licensed under the Apache License 2.0 (the "License"). You may not use
* this file except in compliance with the License. You can obtain a copy
@@ -130,11 +130,8 @@ static size_t internal_trace_cb(const char *buf, size_t cnt,
{
int ret = 0;
tracedata *trace_data = vdata;
- union {
- CRYPTO_THREAD_ID tid;
- unsigned long ltid;
- } tid;
- char buffer[256];
+ char buffer[256], *hex;
+ CRYPTO_THREAD_ID tid;
switch (cmd) {
case OSSL_TRACE_CTRL_BEGIN:
@@ -142,11 +139,11 @@ static size_t internal_trace_cb(const char *buf, size_t cnt,
return 0;
trace_data->ingroup = 1;
- tid.ltid = 0;
- tid.tid = CRYPTO_THREAD_get_current_id();
-
- BIO_snprintf(buffer, sizeof(buffer), "TRACE[%lx]:%s: ", tid.ltid,
- OSSL_trace_get_category_name(category));
+ tid = CRYPTO_THREAD_get_current_id();
+ hex = OPENSSL_buf2hexstr((const unsigned char *)&tid, sizeof(tid));
+ BIO_snprintf(buffer, sizeof(buffer), "TRACE[%s]:%s: ",
+ hex, OSSL_trace_get_category_name(category));
+ OPENSSL_free(hex);
BIO_ctrl(trace_data->bio, PREFIX_CTRL_SET_PREFIX,
strlen(buffer), buffer);
break;