]> git.michaelhowe.org Git - packages/o/openafs.git/commitdiff
fs: Fix improper use of readlink
authorStephan Wiesand <stephan.wiesand@desy.de>
Thu, 10 Apr 2014 15:59:24 +0000 (17:59 +0200)
committerStephan Wiesand <stephan.wiesand@desy.de>
Wed, 4 Jun 2014 14:46:41 +0000 (10:46 -0400)
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 <buildbot@rampaginggeek.com>
Reviewed-by: Andrew Deason <adeason@sinenomine.net>
Reviewed-by: Chas Williams - CONTRACTOR <chas@cmf.nrl.navy.mil>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Reviewed-by: D Brashear <shadow@your-file-system.com>
Reviewed-by: Stephan Wiesand <stephan.wiesand@desy.de>
src/venus/fs.c

index 13d6585c4e13eda2e2912579345727804aeb24d0..37b1788769f46f902c6bbb071de164816bc1162d 100644 (file)
@@ -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",