From: Tobias Stoeckmann Date: Mon, 20 Jul 2015 14:42:40 +0000 (-0400) Subject: util: avoid off-by-one on long symlinks X-Git-Tag: v1.43-WIP-2016-03-15~56^2~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9bcfea2a892de55e71f530472bef9b403f034edb;p=thirdparty%2Fe2fsprogs.git 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 --- diff --git a/util/symlinks.c b/util/symlinks.c index abb33f8b2..3acebe7a2 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; }