]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
lsblk: fix readlink() usage
authorKarel Zak <kzak@redhat.com>
Fri, 18 Feb 2011 13:36:04 +0000 (14:36 +0100)
committerKarel Zak <kzak@redhat.com>
Mon, 18 Apr 2011 12:30:55 +0000 (14:30 +0200)
Reported-by: Steve Grubb <sgrubb@redhat.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
misc-utils/lsblk.c

index b07bfb49a679dd935e50948541a376b5e8ec78ba..bbc94b5fc468a66d136a5a026705146a92439f87 100644 (file)
@@ -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;