From: Simon Wilkinson Date: Fri, 1 Mar 2013 12:12:07 +0000 (+0000) Subject: up: Fix improper use of readlink X-Git-Tag: upstream/1.8.0_pre1^2~1366 X-Git-Url: https://git.michaelhowe.org/gitweb/?a=commitdiff_plain;h=80875f8aa1540bf032073a4843566bbe6b1fe301;p=packages%2Fo%2Fopenafs.git up: Fix improper use of readlink 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 Reviewed-by: Jeffrey Altman Reviewed-by: Derrick Brashear --- diff --git a/src/venus/up.c b/src/venus/up.c index f253875a9..d7ee2a652 100644 --- a/src/venus/up.c +++ b/src/venus/up.c @@ -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 ");