make xmalloc_open_zipped_read_close result NUL terminated
authorDenys Vlasenko <vda.linux@googlemail.com>
Sat, 6 Dec 2014 23:49:55 +0000 (00:49 +0100)
committerDenys Vlasenko <vda.linux@googlemail.com>
Sat, 6 Dec 2014 23:49:55 +0000 (00:49 +0100)
Compat with xmalloc_open_read_close

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
archival/libarchive/open_transformer.c

index 9d762a8599489b3748f3300939df3ba370749e78..ab6aa3afc5379b189f9fbd7ebb086c20150164ad 100644 (file)
@@ -43,8 +43,9 @@ ssize_t FAST_FUNC transformer_write(transformer_state_t *xstate, const void *buf
                        nwrote = -1;
                        goto ret;
                }
-               xstate->mem_output_buf = xrealloc(xstate->mem_output_buf, size);
+               xstate->mem_output_buf = xrealloc(xstate->mem_output_buf, size + 1);
                memcpy(xstate->mem_output_buf + pos, buf, bufsize);
+               xstate->mem_output_buf[size] = '\0';
                nwrote = bufsize;
        } else {
                nwrote = full_write(xstate->dst_fd, buf, bufsize);