From ffd53c0fe893f8bc9f64706c1230134dde6f654e Mon Sep 17 00:00:00 2001 From: David Sterba Date: Wed, 29 Apr 2015 18:08:28 +0200 Subject: [PATCH] btrfs-progs: restore: use bigger buffer for output path name Signed-off-by: David Sterba --- cmds-restore.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/cmds-restore.c b/cmds-restore.c index 059fbf2c..d68f23d3 100644 --- a/cmds-restore.c +++ b/cmds-restore.c @@ -1412,7 +1412,7 @@ int cmd_restore(int argc, char **argv) { struct btrfs_root *root; struct btrfs_key key; - char dir_name[128]; + char dir_name[PATH_MAX]; u64 tree_location = 0; u64 fs_location = 0; u64 root_objectid = 0; @@ -1544,6 +1544,11 @@ int cmd_restore(int argc, char **argv) memset(path_name, 0, PATH_MAX); + if (strlen(argv[optind + 1]) >= PATH_MAX) { + fprintf(stderr, "ERROR: path too long\n"); + ret = 1; + goto out; + } strncpy(dir_name, argv[optind + 1], sizeof dir_name); dir_name[sizeof dir_name - 1] = 0;