util: avoid off-by-one on long symlinks

readlink does not nul terminate its result, therefore one extra byte
has to be taken into account.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
test-maint
Tobias Stoeckmann 2015-07-20 10:42:40 -04:00 committed by Theodore Ts'o
parent 8815116d1d
commit 9bcfea2a89
1 changed files with 1 additions and 1 deletions

View File

@ -166,7 +166,7 @@ static void fix_symlink (char *path, dev_t my_dev)
struct stat stbuf, lstbuf;
int c, fix_abs = 0, fix_messy = 0, fix_long = 0;
if ((c = readlink(path, lpath, sizeof(lpath))) == -1) {
if ((c = readlink(path, lpath, sizeof(lpath) - 1)) == -1) {
perror(path);
return;
}