From: Tim Kientzle Date: Tue, 24 May 2011 03:22:31 +0000 (-0400) Subject: Issue 157: Found by GCC 4.6: The temp buffer, which was set up X-Git-Tag: v3.0.0a~312 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e39bac1b109fa22f438ea40db77565791df2154c;p=thirdparty%2Flibarchive.git Issue 157: Found by GCC 4.6: The temp buffer, which was set up specifically to avoid walking off the end of the provided input data, wasn't being used. Possible ramification: libarchive could segfault when writing shar files with uuencode encoding of file bodies, if the data being read happened to end exactly at the end of an allocated page. SVN-Revision: 3375 --- diff --git a/libarchive/archive_write_set_format_shar.c b/libarchive/archive_write_set_format_shar.c index ba8fcd12a..0287021f3 100644 --- a/libarchive/archive_write_set_format_shar.c +++ b/libarchive/archive_write_set_format_shar.c @@ -412,7 +412,7 @@ uuencode_group(const char _in[3], char out[4]) static int _uuencode_line(struct archive_write *a, struct shar *shar, const char *inbuf, size_t len) { - char tmp_buf[3], *buf; + char *buf; size_t alloc_len; /* len <= 45 -> expanded to 60 + len byte + new line */ @@ -431,13 +431,14 @@ _uuencode_line(struct archive_write *a, struct shar *shar, const char *inbuf, si buf += 4; } if (len != 0) { + char tmp_buf[3]; tmp_buf[0] = inbuf[0]; if (len == 1) tmp_buf[1] = '\0'; else tmp_buf[1] = inbuf[1]; tmp_buf[2] = '\0'; - uuencode_group(inbuf, buf); + uuencode_group(tmp_buf, buf); buf += 4; } *buf++ = '\n';