btrfs-progs: restore: fix off-by-one len check
authorVincent Stehlé <vincent.stehle@freescale.com>
Thu, 8 Oct 2015 08:47:09 +0000 (10:47 +0200)
committerDavid Sterba <dsterba@suse.com>
Fri, 16 Oct 2015 17:37:44 +0000 (19:37 +0200)
Fix a check of len versus PATH_MAX in function copy_symlink(), to
account for the terminating null byte.

Resolves-Coverity-CID: 1296749
Signed-off-by: Vincent Stehlé <vincent.stehle@freescale.com>
Signed-off-by: David Sterba <dsterba@suse.com>
cmds-restore.c

index 8fc8b2a..a1445d4 100644 (file)
@@ -863,7 +863,7 @@ static int copy_symlink(struct btrfs_root *root, struct btrfs_key *key,
 
        len = btrfs_file_extent_inline_item_len(leaf,
                        btrfs_item_nr(path->slots[0]));
-       if (len > PATH_MAX) {
+       if (len >= PATH_MAX) {
                fprintf(stderr, "Symlink '%s' target length %d is longer than PATH_MAX\n",
                                fs_name, len);
                ret = -1;