Skip to content

Commit

Permalink
perf buildid: Fix possible unterminated readlink() result buffer
Browse files Browse the repository at this point in the history
The readlink function doesn't guarantee that a '\0' will be put at the
end of the provided buffer if there is no space left.

No need to do "buf[len] = '\0';" since the buffer is allocated with
zalloc().

Link: http://lkml.kernel.org/r/4E986ABF.9040706@intra2net.com
Signed-off-by: Thomas Jarosch <thomas.jarosch@intra2net.com>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
  • Loading branch information
Thomas Jarosch authored and Arnaldo Carvalho de Melo committed Oct 14, 2011
1 parent 0361fc2 commit 6c3c5b2
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion tools/perf/util/header.c
Original file line number Diff line number Diff line change
Expand Up @@ -1289,7 +1289,7 @@ int build_id_cache__remove_s(const char *sbuild_id, const char *debugdir)
if (access(linkname, F_OK))
goto out_free;

if (readlink(linkname, filename, size) < 0)
if (readlink(linkname, filename, size - 1) < 0)
goto out_free;

if (unlink(linkname))
Expand Down

0 comments on commit 6c3c5b2

Please sign in to comment.