Subversion Repositories

?revision_form?Rev ?revision_input??revision_submit??revision_endform?

Blame | Last modification | View Log | RSS feed

Description: Fix memory leak in th_get_pathname
 by making the buffer, where prefix and filename are concatenated, static
 and returning that instead of a pointer to a copy of a local buffer.
Author: Per Lidén <per@fukt.bth.se>
Bug-Ubuntu: https://bugs.launchpad.net/ubuntu/+source/libtar/+bug/41804

--- a/lib/decode.c
+++ b/lib/decode.c
@@ -26,7 +26,7 @@
 char *
 th_get_pathname(TAR *t)
 {
-       char filename[MAXPATHLEN];
+       static char filename[MAXPATHLEN];
 
        if (t->th_buf.gnu_longname)
                return t->th_buf.gnu_longname;
@@ -35,11 +35,11 @@ th_get_pathname(TAR *t)
        {
                snprintf(filename, sizeof(filename), "%.155s/%.100s",
                         t->th_buf.prefix, t->th_buf.name);
-               return strdup(filename);
+               return filename;
        }
 
        snprintf(filename, sizeof(filename), "%.100s", t->th_buf.name);
-       return strdup(filename);
+       return filename;
 }