]> git.ipfire.org Git - thirdparty/libarchive.git/commitdiff
Issue 157: Found by GCC 4.6: The temp buffer, which was set up
authorTim Kientzle <kientzle@gmail.com>
Tue, 24 May 2011 03:22:31 +0000 (23:22 -0400)
committerTim Kientzle <kientzle@gmail.com>
Tue, 24 May 2011 03:22:31 +0000 (23:22 -0400)
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

libarchive/archive_write_set_format_shar.c

index ba8fcd12ab6967ef067641235e497b4f29d9b40a..0287021f3ffb4bec85e2024d8c296dd951375dbb 100644 (file)
@@ -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';