Skip to content

Commit

Permalink
Addresses #89, hts_log strings
Browse files Browse the repository at this point in the history
Fixes potential buffer overflow condition in prior commit

Co-authored-by: Nicholas Wilson
  • Loading branch information
jblachly committed Jul 29, 2021
1 parent 4d46734 commit 11be3de
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions source/htslib/hts_log.d
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ void hts_log_error(const(char)[] ctx, string msg)
{
string open_error_color = "\x1b[0;31m";
string close_color = "\x1b[0m";
hts_log(htsLogLevel.HTS_LOG_ERROR, toStringz(ctx), "%*s%*s%*s",
hts_log(htsLogLevel.HTS_LOG_ERROR, toStringz(ctx), "%.*s%.*s%.*s",
cast(int)open_error_color.length, open_error_color.ptr,
cast(int)msg.length, msg.ptr,
cast(int)close_color.length, close_color.ptr);
Expand All @@ -89,7 +89,7 @@ void hts_log_warning(const(char)[] ctx, string msg)
{
string open_warning_color = "\x1b[0;33m";
string close_color = "\x1b[0m";
hts_log(htsLogLevel.HTS_LOG_WARNING, toStringz(ctx), "%*s%*s%*s",
hts_log(htsLogLevel.HTS_LOG_WARNING, toStringz(ctx), "%.*s%.*s%.*s",
cast(int)open_warning_color.length, open_warning_color.ptr,
cast(int)msg.length, msg.ptr,
cast(int)close_color.length, close_color.ptr);
Expand All @@ -101,7 +101,7 @@ void hts_log_info(const(char)[] ctx, string msg)
{
string open_info_color = "\x1b[0;32m";
string close_color = "\x1b[0m";
hts_log(htsLogLevel.HTS_LOG_INFO, toStringz(ctx), "%*s%*s%*s",
hts_log(htsLogLevel.HTS_LOG_INFO, toStringz(ctx), "%.*s%.*s%.*s",
cast(int)open_info_color.length, open_info_color.ptr,
cast(int)msg.length, msg.ptr,
cast(int)close_color.length, close_color.ptr);
Expand All @@ -113,7 +113,7 @@ void hts_log_debug(const(char)[] ctx, string msg)
{
string open_debug_color = "\x1b[0;36m";
string close_color = "\x1b[0m";
hts_log(htsLogLevel.HTS_LOG_DEBUG, toStringz(ctx), "%*s%*s%*s",
hts_log(htsLogLevel.HTS_LOG_DEBUG, toStringz(ctx), "%.*s%.*s%.*s",
cast(int)open_debug_color.length, open_debug_color.ptr,
cast(int)msg.length, msg.ptr,
cast(int)close_color.length, close_color.ptr);
Expand All @@ -125,7 +125,7 @@ void hts_log_trace(const(char)[] ctx, string msg)
{
string open_trace_color = "\x1b[1;36m";
string close_color = "\x1b[0m";
hts_log(htsLogLevel.HTS_LOG_TRACE, toStringz(ctx), "%*s%*s%*s",
hts_log(htsLogLevel.HTS_LOG_TRACE, toStringz(ctx), "%.*s%.*s%.*s",
cast(int)open_trace_color.length, open_trace_color.ptr,
cast(int)msg.length, msg.ptr,
cast(int)close_color.length, close_color.ptr);
Expand Down

0 comments on commit 11be3de

Please sign in to comment.