Issue #767: Buffer overflow printing a filename 72/134772/1
authorTim Kientzle <kientzle@acm.org>
Sun, 21 Aug 2016 17:51:43 +0000 (10:51 -0700)
committerDongHun Kwak <dh0128.kwak@samsung.com>
Tue, 20 Jun 2017 04:06:02 +0000 (13:06 +0900)
commit7799cabd374113a9aae8b9b8c79d09a056540115
tree861961ea273606596d9d0ed3fcc10f9f493c423e
parentfc700e02c22f88029955d00ece26ba9b39394d31
Issue #767: Buffer overflow printing a filename

The safe_fprintf function attempts to ensure clean output for an
arbitrary sequence of bytes by doing a trial conversion of the
multibyte characters to wide characters -- if the resulting wide
character is printable then we pass through the corresponding bytes
unaltered, otherwise, we convert them to C-style ASCII escapes.

The stack trace in Issue #767 suggest that the 20-byte buffer
was getting overflowed trying to format a non-printable multibyte
character.  This should only happen if there is a valid multibyte
character of more than 5 bytes that was unprintable.  (Each byte
would get expanded to a four-charcter octal-style escape of the form
"\123" resulting in >20 characters for the >5 byte multibyte character.)

I've not been able to reproduce this, but have expanded the conversion
buffer to 128 bytes on the belief that no multibyte character set
has a single character of more than 32 bytes.

Change-Id: I6ac04d0c27458f8953263a0ddee5aec0c1c54afa
Signed-off-by: DongHun Kwak <dh0128.kwak@samsung.com>
tar/util.c