Skip to content

Commit

Permalink
fix snprintf warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
goblinhack committed Jan 9, 2025
1 parent d3aec67 commit a9199cc
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/log.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,11 @@ static void err_(const char *fmt, va_list args)
len = (int) strlen(buf);
}

snprintf(buf + len, MAXLONGSTR - len, "ERROR: %%%%fg=red$%s%%%%fg=reset$", error_buf);
if (snprintf(buf + len, MAXLONGSTR - len, "ERROR: %%%%fg=red$%s%%%%fg=reset$", error_buf) < 0) {
ERR("truncation");
return;
}

putf(MY_STDERR, buf);
putf(MY_STDOUT, buf);

Expand Down Expand Up @@ -243,7 +247,11 @@ static void py_err_(const char *fmt, va_list args)
len = (int) strlen(buf);
}

snprintf(buf + len, MAXLONGSTR - len, "ERROR: %%%%fg=red$%s%%%%fg=reset$", error_buf);
if (snprintf(buf + len, MAXLONGSTR - len, "ERROR: %%%%fg=red$%s%%%%fg=reset$", error_buf) < 0) {
ERR("truncation");
return;
}

putf(MY_STDERR, buf);
putf(MY_STDOUT, buf);

Expand Down

0 comments on commit a9199cc

Please sign in to comment.