csomh / rpms / rsync

Forked from rpms/rsync 3 years ago
Clone
f090e2
diff --git a/log.c b/log.c
f090e2
index 34a013b..1aca728 100644
f090e2
--- a/log.c
f090e2
+++ b/log.c
f090e2
@@ -377,10 +377,13 @@ output_msg:
f090e2
 				filtered_fwrite(f, convbuf, outbuf.len, 0);
f090e2
 				outbuf.len = 0;
f090e2
 			}
f090e2
-			if (!ierrno || ierrno == E2BIG)
f090e2
-				continue;
f090e2
-			fprintf(f, "\\#%03o", CVAL(inbuf.buf, inbuf.pos++));
f090e2
-			inbuf.len--;
f090e2
+			/* Log one byte of illegal/incomplete sequence and continue with
f090e2
+			 * the next character. Check that the buffer is non-empty for the
f090e2
+			 * sake of robustness. */
f090e2
+			if ((ierrno == EILSEQ || ierrno == EINVAL) && inbuf.len) {
f090e2
+				fprintf(f, "\\#%03o", CVAL(inbuf.buf, inbuf.pos++));
f090e2
+				inbuf.len--;
f090e2
+			}
f090e2
 		}
f090e2
 	} else
f090e2
 #endif