commit:     e73183f42ef1b3915fca02fe3da044986c4cf98b
Author:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
AuthorDate: Mon Jun 20 17:45:05 2016 +0000
Commit:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
CommitDate: Mon Jun 20 17:45:05 2016 +0000
URL:        https://gitweb.gentoo.org/proj/pax-utils.git/commit/?id=e73183f4

ar: make sure file name is always NUL terminated

 paxinc.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/paxinc.c b/paxinc.c
index bd13ec4..068aa60 100644
--- a/paxinc.c
+++ b/paxinc.c
@@ -109,9 +109,10 @@ close_and_ret:
                        if (read(ar->fd, ret.buf.formatted.name, len) != len)
                                goto close_and_ret;
                } else {
-                       s = alloca(sizeof(char) * len);
+                       s = alloca(sizeof(char) * len + 1);
                        if (read(ar->fd, s, len) != len)
                                goto close_and_ret;
+                       s[len] = '\0';
                }
        } else if (s[0] == '/' && s[1] >= '0' && s[1] <= '9') {
                /* GNU extended filename */

Reply via email to