summaryrefslogtreecommitdiffstats
path: root/crypto/mem_dbg.c
diff options
context:
space:
mode:
authorRich Salz <rsalz@openssl.org>2017-06-14 20:34:37 -0400
committerPauli <paul.dale@oracle.com>2017-07-05 11:32:35 +1000
commit0904e79a6e6109240d5a552f2699408b26cf63ee (patch)
treedf0b4928a751b05779164cf7dd84265407bea332 /crypto/mem_dbg.c
parentff281ee8369350d88e8b57af139614f5683e1e8c (diff)
Undo commit d420ac2
[extended tests] Original text: Use BUF_strlcpy() instead of strcpy(). Use BUF_strlcat() instead of strcat(). Use BIO_snprintf() instead of sprintf(). In some cases, keep better track of buffer lengths. This is part of a large change submitted by Markus Friedl <markus@openbsd.org> Reviewed-by: Tim Hudson <tjh@openssl.org> Reviewed-by: Paul Dale <paul.dale@oracle.com> (Merged from https://github.com/openssl/openssl/pull/3701)
Diffstat (limited to 'crypto/mem_dbg.c')
-rw-r--r--crypto/mem_dbg.c23
1 files changed, 8 insertions, 15 deletions
diff --git a/crypto/mem_dbg.c b/crypto/mem_dbg.c
index 4c4e7d3f12..c0bb2be1f1 100644
--- a/crypto/mem_dbg.c
+++ b/crypto/mem_dbg.c
@@ -467,24 +467,19 @@ static void print_leak(const MEM *m, MEM_LEAK *l)
} tid;
CRYPTO_THREAD_ID ti;
-#define BUF_REMAIN (sizeof buf - (size_t)(bufp - buf))
-
lcl = localtime(&m->time);
- BIO_snprintf(bufp, BUF_REMAIN, "[%02d:%02d:%02d] ",
- lcl->tm_hour, lcl->tm_min, lcl->tm_sec);
+ sprintf(bufp, "[%02d:%02d:%02d] ", lcl->tm_hour, lcl->tm_min, lcl->tm_sec);
bufp += strlen(bufp);
- BIO_snprintf(bufp, BUF_REMAIN, "%5lu file=%s, line=%d, ",
- m->order, m->file, m->line);
+ sprintf(bufp, "%5lu file=%s, line=%d, ", m->order, m->file, m->line);
bufp += strlen(bufp);
tid.ltid = 0;
tid.tid = m->threadid;
- BIO_snprintf(bufp, BUF_REMAIN, "thread=%lu, ", tid.ltid);
+ sprintf(bufp, "thread=%lu, ", tid.ltid);
bufp += strlen(bufp);
- BIO_snprintf(bufp, BUF_REMAIN, "number=%d, address=%p\n",
- m->num, m->addr);
+ sprintf(bufp, "number=%d, address=%p\n", m->num, m->addr);
bufp += strlen(bufp);
l->print_cb(buf, strlen(buf), l->print_cb_arg);
@@ -506,20 +501,18 @@ static void print_leak(const MEM *m, MEM_LEAK *l)
memset(buf, '>', ami_cnt);
tid.ltid = 0;
tid.tid = amip->threadid;
- BIO_snprintf(buf + ami_cnt, sizeof buf - ami_cnt,
- " thread=%lu, file=%s, line=%d, info=\"",
- tid.ltid, amip->file,
- amip->line);
+ sprintf(buf + ami_cnt, " thread=%lu, file=%s, line=%d, info=\"",
+ tid.ltid, amip->file, amip->line);
buf_len = strlen(buf);
info_len = strlen(amip->info);
if (128 - buf_len - 3 < info_len) {
memcpy(buf + buf_len, amip->info, 128 - buf_len - 3);
buf_len = 128 - 3;
} else {
- OPENSSL_strlcpy(buf + buf_len, amip->info, sizeof buf - buf_len);
+ strcpy(buf + buf_len, amip->info);
buf_len = strlen(buf);
}
- BIO_snprintf(buf + buf_len, sizeof buf - buf_len, "\"\n");
+ sprintf(buf + buf_len, "\"\n");
l->print_cb(buf, strlen(buf), l->print_cb_arg);