From: Karel Zak Date: Fri, 18 Feb 2011 13:36:04 +0000 (+0100) Subject: lsblk: fix readlink() usage X-Git-Tag: v2.19.1-rc1~65 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=fde25e6be6e00a0998eb58b4b9d0d0b9ad65dbfd;p=thirdparty%2Futil-linux.git lsblk: fix readlink() usage Reported-by: Steve Grubb Signed-off-by: Karel Zak --- diff --git a/misc-utils/lsblk.c b/misc-utils/lsblk.c index b07bfb49a6..bbc94b5fc4 100644 --- a/misc-utils/lsblk.c +++ b/misc-utils/lsblk.c @@ -768,7 +768,7 @@ static int process_one_device(char *devname) { struct blkdev_cxt parent = {}, cxt = {}; struct stat st; - char buf[PATH_MAX]; + char buf[PATH_MAX + 1]; dev_t disk = 0; if (stat(devname, &st) || !S_ISBLK(st.st_mode)) { @@ -795,7 +795,7 @@ static int process_one_device(char *devname) major(st.st_rdev), minor(st.st_rdev)); diskname = xstrdup(buf); - len = readlink(path, buf, sizeof(buf)); + len = readlink(path, buf, PATH_MAX); if (len < 0) { warn(_("%s: failed to read link"), path); return EXIT_FAILURE;