Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
3 | magnus | 1 | Description: Fix memory leak in th_get_pathname |
2 | by making the buffer, where prefix and filename are concatenated, static |
||
3 | and returning that instead of a pointer to a copy of a local buffer. |
||
4 | Author: Per Lidén <per@fukt.bth.se> |
||
5 | Bug-Ubuntu: https://bugs.launchpad.net/ubuntu/+source/libtar/+bug/41804 |
||
6 | |||
7 | --- a/lib/decode.c |
||
8 | +++ b/lib/decode.c |
||
9 | @@ -26,7 +26,7 @@ |
||
10 | char * |
||
11 | th_get_pathname(TAR *t) |
||
12 | { |
||
13 | - char filename[MAXPATHLEN]; |
||
14 | + static char filename[MAXPATHLEN]; |
||
15 | |||
16 | if (t->th_buf.gnu_longname) |
||
17 | return t->th_buf.gnu_longname; |
||
18 | @@ -35,11 +35,11 @@ th_get_pathname(TAR *t) |
||
19 | { |
||
20 | snprintf(filename, sizeof(filename), "%.155s/%.100s", |
||
21 | t->th_buf.prefix, t->th_buf.name); |
||
22 | - return strdup(filename); |
||
23 | + return filename; |
||
24 | } |
||
25 | |||
26 | snprintf(filename, sizeof(filename), "%.100s", t->th_buf.name); |
||
27 | - return strdup(filename); |
||
28 | + return filename; |
||
29 | } |
||
30 | |||
31 |