summaryrefslogtreecommitdiff
path: root/receiver.c
diff options
context:
space:
mode:
authorWayne Davison <wayned@samba.org>2010-11-26 09:35:43 -0800
committerWayne Davison <wayned@samba.org>2010-11-26 09:35:43 -0800
commit9f5c16e51d274ad9c11b58396c0f9627d95611fb (patch)
tree9f5eb5f0ff2669853ef363b0c5f559d65eece418 /receiver.c
parent8484ddd3d1e667eb209328c17c389972adc4f14a (diff)
downloadrsync-9f5c16e51d274ad9c11b58396c0f9627d95611fb.tar.gz
Avoid splitting a multi-byte character when trimming a name.
Fixes bug 7816.
Diffstat (limited to 'receiver.c')
-rw-r--r--receiver.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/receiver.c b/receiver.c
index ba3566b8..0bc65177 100644
--- a/receiver.c
+++ b/receiver.c
@@ -129,6 +129,14 @@ int get_tmpname(char *fnametmp, const char *fname, BOOL make_unique)
added = maxname - 1;
suf = fnametmp + length + added;
+ /* Trim any dangling high-bit chars if the first-trimmed char (if any) is
+ * also a high-bit char, just in case we cut into a multi-byte sequence.
+ * We are guaranteed to stop because of the leading '.' we added. */
+ if ((int)f[added] & 0x80) {
+ while ((int)suf[-1] & 0x80)
+ suf--;
+ }
+
if (make_unique) {
static unsigned counter_limit;
unsigned counter;