Commit d9c0051f authored by Wayne Davison's avatar Wayne Davison

In log_formatted(), add the newline to the format string so

that we can call rwrite() instead of rprintf().
parent 126e7aff
...@@ -363,6 +363,12 @@ static void log_formatted(enum logcode code, char *format, char *op, ...@@ -363,6 +363,12 @@ static void log_formatted(enum logcode code, char *format, char *op,
* copy in the terminating null of the inserted strings, but * copy in the terminating null of the inserted strings, but
* rather keep going until we reach the null of the format. */ * rather keep going until we reach the null of the format. */
total = strlcpy(buf, format, sizeof buf); total = strlcpy(buf, format, sizeof buf);
if (total > MAXPATHLEN) {
rprintf(FERROR, "log-format string is WAY too long!\n");
exit_cleanup(RERR_MESSAGEIO);
}
buf[total++] = '\n';
buf[total] = '\0';
for (p = buf; (p = strchr(p, '%')) != NULL; ) { for (p = buf; (p = strchr(p, '%')) != NULL; ) {
s = p++; s = p++;
...@@ -517,7 +523,7 @@ static void log_formatted(enum logcode code, char *format, char *op, ...@@ -517,7 +523,7 @@ static void log_formatted(enum logcode code, char *format, char *op,
/* Subtract the length of the escape from the string's size. */ /* Subtract the length of the escape from the string's size. */
total -= p - s; total -= p - s;
if (len + total >= sizeof buf) { if (len + total >= (size_t)sizeof buf) {
rprintf(FERROR, rprintf(FERROR,
"buffer overflow expanding %%%c -- exiting\n", "buffer overflow expanding %%%c -- exiting\n",
p[-1]); p[-1]);
...@@ -537,7 +543,7 @@ static void log_formatted(enum logcode code, char *format, char *op, ...@@ -537,7 +543,7 @@ static void log_formatted(enum logcode code, char *format, char *op,
p = s + len; p = s + len;
} }
rprintf(code, "%s\n", buf); rwrite(code, buf, total);
} }
int log_format_has(const char *format, char esc) int log_format_has(const char *format, char esc)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment