summaryrefslogtreecommitdiff
path: root/log.c
diff options
context:
space:
mode:
authorWayne Davison <wayned@samba.org>2005-03-31 01:09:18 +0000
committerWayne Davison <wayned@samba.org>2005-03-31 01:09:18 +0000
commitd9c0051fae2b69e7aa191ade1091f90c60783a2c (patch)
treef05984b2e1a2be65a09629466c60681c7b6268a2 /log.c
parent126e7affb7a8fd7ca6293ca9c77db3e5319028ad (diff)
downloadrsync-d9c0051fae2b69e7aa191ade1091f90c60783a2c.tar.gz
In log_formatted(), add the newline to the format string so
that we can call rwrite() instead of rprintf().
Diffstat (limited to 'log.c')
-rw-r--r--log.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/log.c b/log.c
index 80aed1d3..9278c42e 100644
--- a/log.c
+++ b/log.c
@@ -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
* rather keep going until we reach the null of the format. */
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; ) {
s = p++;
@@ -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. */
total -= p - s;
- if (len + total >= sizeof buf) {
+ if (len + total >= (size_t)sizeof buf) {
rprintf(FERROR,
"buffer overflow expanding %%%c -- exiting\n",
p[-1]);
@@ -537,7 +543,7 @@ static void log_formatted(enum logcode code, char *format, char *op,
p = s + len;
}
- rprintf(code, "%s\n", buf);
+ rwrite(code, buf, total);
}
int log_format_has(const char *format, char esc)