From 9e227094914d1a74b64f247cb74793c429930b25 Mon Sep 17 00:00:00 2001 From: Stephan Wiesand Date: Thu, 10 Apr 2014 17:59:24 +0200 Subject: [PATCH] fs: Fix improper use of readlink readlink returns a non-NUL terminated buffer. If we are going to terminate its response, we need to make sure that there's space to do so. So the length passed to readlink should be one less than the real length of the buffer. This is a 1.6-only change It is inspired by commit 25011b4544e48dffd5978201669f7b9e23da3144 which cannot be cherry picked due to other missing commits on the 1.6 branch, like 763ec5250deef6f0f8ae1c85b52bac3ffc1a6176. Change-Id: I5c3f2946f7c1b8e935ae46bc195f58e207e115d6 Reviewed-on: http://gerrit.openafs.org/11054 Tested-by: BuildBot Reviewed-by: Andrew Deason Reviewed-by: Chas Williams - CONTRACTOR Reviewed-by: Benjamin Kaduk Reviewed-by: D Brashear Reviewed-by: Stephan Wiesand --- src/venus/fs.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/venus/fs.c b/src/venus/fs.c index 13d6585c4e..37b1788769 100644 --- a/src/venus/fs.c +++ b/src/venus/fs.c @@ -1742,7 +1742,7 @@ ListMountCmd(struct cmd_syndesc *as, void *arock) /* * Read name of resolved file. */ - link_chars_read = readlink(orig_name, true_name, 1024); + link_chars_read = readlink(orig_name, true_name, 1024 - 1); if (link_chars_read <= 0) { fprintf(stderr, "%s: Can't read target name for '%s' symbolic link!\n", @@ -4129,7 +4129,7 @@ FlushMountCmd(struct cmd_syndesc *as, void *arock) /* * Read name of resolved file. */ - link_chars_read = readlink(orig_name, true_name, 1024); + link_chars_read = readlink(orig_name, true_name, 1024 - 1); if (link_chars_read <= 0) { fprintf(stderr, "%s: Can't read target name for '%s' symbolic link!\n",