Matt McCutchen's Web Site
/
rsync
/
rsync.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Changed strcpy() calls into memcpy() calls.
[rsync/rsync.git]
/
log.c
diff --git
a/log.c
b/log.c
index
20132c3
..
ef91f98
100644
(file)
--- a/
log.c
+++ b/
log.c
@@
-37,6
+37,7
@@
extern int msg_fd_out;
extern int allow_8bit_chars;
extern int protocol_version;
extern int preserve_times;
extern int allow_8bit_chars;
extern int protocol_version;
extern int preserve_times;
+extern int in_exit_cleanup;
extern int stdout_format_has_i;
extern int stdout_format_has_o_or_i;
extern int logfile_format_has_i;
extern int stdout_format_has_i;
extern int stdout_format_has_o_or_i;
extern int logfile_format_has_i;
@@
-49,6
+50,8
@@
extern char *logfile_name;
#if defined HAVE_ICONV_OPEN && defined HAVE_ICONV_H
extern iconv_t ic_chck;
#endif
#if defined HAVE_ICONV_OPEN && defined HAVE_ICONV_H
extern iconv_t ic_chck;
#endif
+extern char curr_dir[];
+extern unsigned int module_dirlen;
static int log_initialised;
static int logfile_was_closed;
static int log_initialised;
static int logfile_was_closed;
@@
-88,6
+91,13
@@
struct {
{ 0, NULL }
};
{ 0, NULL }
};
+#define EXIT_OR_RETURN(err) \
+ do { \
+ if (in_exit_cleanup) \
+ return; \
+ exit_cleanup(err); \
+ } while (0)
+
/*
* Map from rsync error code to name, or return NULL.
/*
* Map from rsync error code to name, or return NULL.
@@
-220,13
+230,13
@@
static void filtered_fwrite(FILE *f, const char *buf, int len, int use_isprint)
&& ((use_isprint && !isprint(*(uchar*)s))
|| *(uchar*)s < ' '))) {
if (s != buf && fwrite(buf, s - buf, 1, f) != 1)
&& ((use_isprint && !isprint(*(uchar*)s))
|| *(uchar*)s < ' '))) {
if (s != buf && fwrite(buf, s - buf, 1, f) != 1)
-
exit_cleanup
(RERR_MESSAGEIO);
+
EXIT_OR_RETURN
(RERR_MESSAGEIO);
fprintf(f, "\\#%03o", *(uchar*)s);
buf = s + 1;
}
}
if (buf != end && fwrite(buf, end - buf, 1, f) != 1)
fprintf(f, "\\#%03o", *(uchar*)s);
buf = s + 1;
}
}
if (buf != end && fwrite(buf, end - buf, 1, f) != 1)
-
exit_cleanup
(RERR_MESSAGEIO);
+
EXIT_OR_RETURN
(RERR_MESSAGEIO);
}
/* this is the underlying (unformatted) rsync debugging function. Call
}
/* this is the underlying (unformatted) rsync debugging function. Call
@@
-238,7
+248,7
@@
void rwrite(enum logcode code, char *buf, int len)
FILE *f = NULL;
if (len < 0)
FILE *f = NULL;
if (len < 0)
-
exit_cleanup
(RERR_MESSAGEIO);
+
EXIT_OR_RETURN
(RERR_MESSAGEIO);
if (am_server && msg_fd_out >= 0) {
/* Pass the message to our sibling. */
if (am_server && msg_fd_out >= 0) {
/* Pass the message to our sibling. */
@@
-292,7
+302,7
@@
void rwrite(enum logcode code, char *buf, int len)
f = am_server ? stderr : stdout;
break;
default:
f = am_server ? stderr : stdout;
break;
default:
-
exit_cleanup
(RERR_MESSAGEIO);
+
EXIT_OR_RETURN
(RERR_MESSAGEIO);
}
trailing_CR_or_NL = len && (buf[len-1] == '\n' || buf[len-1] == '\r')
}
trailing_CR_or_NL = len && (buf[len-1] == '\n' || buf[len-1] == '\r')
@@
-384,7
+394,7
@@
void rsyserr(enum logcode code, int errcode, const char *format, ...)
char buf[BIGPATHBUFLEN];
size_t len;
char buf[BIGPATHBUFLEN];
size_t len;
- str
cpy(buf, RSYNC_NAME ": "
);
+ str
lcpy(buf, RSYNC_NAME ": ", sizeof buf
);
len = (sizeof RSYNC_NAME ": ") - 1;
va_start(ap, format);
len = (sizeof RSYNC_NAME ": ") - 1;
va_start(ap, format);
@@
-396,7
+406,7
@@
void rsyserr(enum logcode code, int errcode, const char *format, ...)
": %s (%d)\n", strerror(errcode), errcode);
}
if (len >= sizeof buf)
": %s (%d)\n", strerror(errcode), errcode);
}
if (len >= sizeof buf)
-
exit_cleanup
(RERR_MESSAGEIO);
+
EXIT_OR_RETURN
(RERR_MESSAGEIO);
rwrite(code, buf, len);
}
rwrite(code, buf, len);
}
@@
-434,7
+444,7
@@
static void log_formatted(enum logcode code, char *format, char *op,
total = strlcpy(buf, format, sizeof buf);
if (total > MAXPATHLEN) {
rprintf(FERROR, "log-format string is WAY too long!\n");
total = strlcpy(buf, format, sizeof buf);
if (total > MAXPATHLEN) {
rprintf(FERROR, "log-format string is WAY too long!\n");
-
exit_cleanup
(RERR_MESSAGEIO);
+
EXIT_OR_RETURN
(RERR_MESSAGEIO);
}
buf[total++] = '\n';
buf[total] = '\0';
}
buf[total++] = '\n';
buf[total] = '\0';
@@
-513,6
+523,14
@@
static void log_formatted(enum logcode code, char *format, char *op,
strlcpy(n, buf2, MAXPATHLEN);
else
n = buf2;
strlcpy(n, buf2, MAXPATHLEN);
else
n = buf2;
+ } else if (*n != '/') {
+ pathjoin(buf2, sizeof buf2,
+ curr_dir + module_dirlen, n);
+ clean_fname(buf2, 0);
+ if (fmt[1])
+ strlcpy(n, buf2, MAXPATHLEN);
+ else
+ n = buf2;
} else
clean_fname(n, 0);
if (*n == '/')
} else
clean_fname(n, 0);
if (*n == '/')
@@
-526,15
+544,15
@@
static void log_formatted(enum logcode code, char *format, char *op,
case 'L':
if (hlink && *hlink) {
n = hlink;
case 'L':
if (hlink && *hlink) {
n = hlink;
- str
cpy(buf2, " => "
);
+ str
lcpy(buf2, " => ", sizeof buf2
);
} else if (S_ISLNK(file->mode) && file->u.link) {
n = file->u.link;
} else if (S_ISLNK(file->mode) && file->u.link) {
n = file->u.link;
- str
cpy(buf2, " -> "
);
+ str
lcpy(buf2, " -> ", sizeof buf2
);
} else {
n = "";
if (!fmt[1])
break;
} else {
n = "";
if (!fmt[1])
break;
- str
cpy(buf2, " "
);
+ str
lcpy(buf2, " ", sizeof buf2
);
}
strlcat(fmt, "s", sizeof fmt);
snprintf(buf2 + 4, sizeof buf2 - 4, fmt, n);
}
strlcat(fmt, "s", sizeof fmt);
snprintf(buf2 + 4, sizeof buf2 - 4, fmt, n);
@@
-637,7
+655,7
@@
static void log_formatted(enum logcode code, char *format, char *op,
rprintf(FERROR,
"buffer overflow expanding %%%c -- exiting\n",
p[0]);
rprintf(FERROR,
"buffer overflow expanding %%%c -- exiting\n",
p[0]);
-
exit_cleanup
(RERR_MESSAGEIO);
+
EXIT_OR_RETURN
(RERR_MESSAGEIO);
}
/* Shuffle the rest of the string along to make space for n */
}
/* Shuffle the rest of the string along to make space for n */