Skip to content

Commit

Permalink
Do not call strlen for every character in the log entry
Browse files Browse the repository at this point in the history
  • Loading branch information
NicolasDorier authored and cdecker committed May 22, 2018
1 parent 88053bd commit d9eba0e
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lightningd/log.c
Original file line number Diff line number Diff line change
Expand Up @@ -255,8 +255,10 @@ void logv(struct log *log, enum log_level level, const char *fmt, va_list ap)

l->log = tal_vfmt(l, fmt, ap);

size_t log_len = strlen(l->log);

/* Sanitize any non-printable characters, and replace with '?' */
for (size_t i=0; i<strlen(l->log); i++)
for (size_t i=0; i<log_len; i++)
if (l->log[i] < ' ' || l->log[i] >= 0x7f)
l->log[i] = '?';

Expand Down

0 comments on commit d9eba0e

Please sign in to comment.