]> 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)
committerDerrick Brashear <shadow@your-file-system.com>
Mon, 4 Mar 2013 03:04:25 +0000 (19:04 -0800)
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)

Change-Id: Id9a6f8227d756140960ac295330aaf17dca2ec03
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>
src/venus/up.c

index f253875a9e4db9aa01cefa28fe4e7a197b7a46b6..d7ee2a652c7ed1a693eedd7f8a25f0c3175a6010 100644 (file)
@@ -418,7 +418,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 ");