summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto/mem_dbg.c
diff options
context:
space:
mode:
authormarkus <>2004-04-07 20:42:07 +0000
committermarkus <>2004-04-07 20:42:07 +0000
commit58c08aa241f168c84ce7cc3052454ea59a44eada (patch)
tree1806747a3fda66041a998ca63c763fdcf722450e /src/lib/libcrypto/mem_dbg.c
parent9c1aa44a1eacea897c0432e796b205b8484ff4d2 (diff)
downloadopenbsd-58c08aa241f168c84ce7cc3052454ea59a44eada.tar.gz
openbsd-58c08aa241f168c84ce7cc3052454ea59a44eada.tar.bz2
openbsd-58c08aa241f168c84ce7cc3052454ea59a44eada.zip
import openssl-0.9.7d
Diffstat (limited to 'src/lib/libcrypto/mem_dbg.c')
-rw-r--r--src/lib/libcrypto/mem_dbg.c17
1 files changed, 10 insertions, 7 deletions
diff --git a/src/lib/libcrypto/mem_dbg.c b/src/lib/libcrypto/mem_dbg.c
index 57bd08f65d..e212de27e4 100644
--- a/src/lib/libcrypto/mem_dbg.c
+++ b/src/lib/libcrypto/mem_dbg.c
@@ -597,6 +597,8 @@ static void print_leak(const MEM *m, MEM_LEAK *l)
597 struct tm *lcl = NULL; 597 struct tm *lcl = NULL;
598 unsigned long ti; 598 unsigned long ti;
599 599
600#define BUF_REMAIN (sizeof buf - (size_t)(bufp - buf))
601
600 if(m->addr == (char *)l->bio) 602 if(m->addr == (char *)l->bio)
601 return; 603 return;
602 604
@@ -604,22 +606,22 @@ static void print_leak(const MEM *m, MEM_LEAK *l)
604 { 606 {
605 lcl = localtime(&m->time); 607 lcl = localtime(&m->time);
606 608
607 sprintf(bufp, "[%02d:%02d:%02d] ", 609 BIO_snprintf(bufp, BUF_REMAIN, "[%02d:%02d:%02d] ",
608 lcl->tm_hour,lcl->tm_min,lcl->tm_sec); 610 lcl->tm_hour,lcl->tm_min,lcl->tm_sec);
609 bufp += strlen(bufp); 611 bufp += strlen(bufp);
610 } 612 }
611 613
612 sprintf(bufp, "%5lu file=%s, line=%d, ", 614 BIO_snprintf(bufp, BUF_REMAIN, "%5lu file=%s, line=%d, ",
613 m->order,m->file,m->line); 615 m->order,m->file,m->line);
614 bufp += strlen(bufp); 616 bufp += strlen(bufp);
615 617
616 if (options & V_CRYPTO_MDEBUG_THREAD) 618 if (options & V_CRYPTO_MDEBUG_THREAD)
617 { 619 {
618 sprintf(bufp, "thread=%lu, ", m->thread); 620 BIO_snprintf(bufp, BUF_REMAIN, "thread=%lu, ", m->thread);
619 bufp += strlen(bufp); 621 bufp += strlen(bufp);
620 } 622 }
621 623
622 sprintf(bufp, "number=%d, address=%08lX\n", 624 BIO_snprintf(bufp, BUF_REMAIN, "number=%d, address=%08lX\n",
623 m->num,(unsigned long)m->addr); 625 m->num,(unsigned long)m->addr);
624 bufp += strlen(bufp); 626 bufp += strlen(bufp);
625 627
@@ -641,7 +643,7 @@ static void print_leak(const MEM *m, MEM_LEAK *l)
641 643
642 ami_cnt++; 644 ami_cnt++;
643 memset(buf,'>',ami_cnt); 645 memset(buf,'>',ami_cnt);
644 sprintf(buf + ami_cnt, 646 BIO_snprintf(buf + ami_cnt, sizeof buf - ami_cnt,
645 " thread=%lu, file=%s, line=%d, info=\"", 647 " thread=%lu, file=%s, line=%d, info=\"",
646 amip->thread, amip->file, amip->line); 648 amip->thread, amip->file, amip->line);
647 buf_len=strlen(buf); 649 buf_len=strlen(buf);
@@ -653,10 +655,11 @@ static void print_leak(const MEM *m, MEM_LEAK *l)
653 } 655 }
654 else 656 else
655 { 657 {
656 strcpy(buf + buf_len, amip->info); 658 BUF_strlcpy(buf + buf_len, amip->info,
659 sizeof buf - buf_len);
657 buf_len = strlen(buf); 660 buf_len = strlen(buf);
658 } 661 }
659 sprintf(buf + buf_len, "\"\n"); 662 BIO_snprintf(buf + buf_len, sizeof buf - buf_len, "\"\n");
660 663
661 BIO_puts(l->bio,buf); 664 BIO_puts(l->bio,buf);
662 665