From 9bcfea2a892de55e71f530472bef9b403f034edb Mon Sep 17 00:00:00 2001 From: Tobias Stoeckmann Date: Mon, 20 Jul 2015 10:42:40 -0400 Subject: [PATCH] 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 Signed-off-by: Theodore Ts'o --- util/symlinks.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/util/symlinks.c b/util/symlinks.c index abb33f8..3acebe7 100644 --- a/util/symlinks.c +++ b/util/symlinks.c @@ -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; } -- 1.8.3.1