]> git.michaelhowe.org Git - packages/o/openafs.git/commitdiff
up: Fix improper use of readlink
authorSimon Wilkinson <sxw@your-file-system.com>
Fri, 1 Mar 2013 12:12:07 +0000 (12:12 +0000)
committerStephan Wiesand <stephan.wiesand@desy.de>
Fri, 22 Mar 2013 12:56:53 +0000 (05:56 -0700)
readlink returns a non-NUL terminated string. If the string must be
terminated, we need to have space in the buffer for it. So, the
buffer passed to readlink must be 1 less than the real length of
the buffer.

Caught by coverity (#985597, #985610)

Reviewed-on: http://gerrit.openafs.org/9329
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Jeffrey Altman <jaltman@your-file-system.com>
Reviewed-by: Derrick Brashear <shadow@your-file-system.com>
(cherry picked from commit 80875f8aa1540bf032073a4843566bbe6b1fe301)

Change-Id: I1dd039bfceaff7891c9145cf4799469b2de2f23a
Reviewed-on: http://gerrit.openafs.org/9371
Reviewed-by: Andrew Deason <adeason@sinenomine.net>
Tested-by: Andrew Deason <adeason@sinenomine.net>
Reviewed-by: Paul Smeddle <paul.smeddle@gmail.com>
Reviewed-by: Stephan Wiesand <stephan.wiesand@desy.de>
src/venus/up.c

index e21cfffeebd4d73d519ea4fad6d50484269eb35f..2b79e9ffbe61dcd1bac430b9801c20b89f6b475c 100644 (file)
@@ -440,7 +440,7 @@ Copy(char *file1, char *file2, short recursive, int level)
            fflush(stdout);
        }
 
-       n = readlink(file1, linkvalue, sizeof(linkvalue));
+       n = readlink(file1, linkvalue, sizeof(linkvalue)-1);
        if (n == -1) {
            fprintf(stderr, "Could not read symbolic link %s\n", file1);
            perror("read link ");