Skip to content

Commit

Permalink
Try to fix the iconv crash in bug 11338.
Browse files Browse the repository at this point in the history
Applying Michal Ruprich's suggested patch for the rwrite() function that
should hopefully help with a bug that I couldn't reproduce.
  • Loading branch information
Wayne Davison committed Mar 16, 2019
1 parent d47d379 commit c0c6a97
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions log.c
Original file line number Diff line number Diff line change
Expand Up @@ -378,10 +378,13 @@ void rwrite(enum logcode code, const char *buf, int len, int is_utf8)
filtered_fwrite(f, convbuf, outbuf.len, 0);
outbuf.len = 0;
}
if (!ierrno || ierrno == E2BIG)
continue;
fprintf(f, "\\#%03o", CVAL(inbuf.buf, inbuf.pos++));
inbuf.len--;
/* Log one byte of illegal/incomplete sequence and continue with
* the next character. Check that the buffer is non-empty for the
* sake of robustness. */
if ((ierrno == EILSEQ || ierrno == EINVAL) && inbuf.len) {
fprintf(f, "\\#%03o", CVAL(inbuf.buf, inbuf.pos++));
inbuf.len--;
}
}
} else
#endif
Expand Down

0 comments on commit c0c6a97

Please sign in to comment.