From 9e40f4f965dbc635410c6e3010a3b311ffddcb6d Mon Sep 17 00:00:00 2001 From: Yuezhang Mo Date: Mon, 4 Sep 2023 15:51:16 +0800 Subject: [PATCH] exfatprogs: remove the limitation that the device path length cannot exceed 254 bytes Since the copy of the device path in exfat_user_input is only 255 bytes, if the device path length is greater than 254, these tools will not work. To remove this limitation, use the user input device path directly instead of a copy in exfat_user_input. Signed-off-by: Yuezhang Mo Reviewed-by: Aoyama Wataru --- dump/dump.c | 3 +-- exfat2img/exfat2img.c | 2 +- fsck/fsck.c | 2 +- include/libexfat.h | 2 +- label/label.c | 3 +-- mkfs/mkfs.c | 3 +-- tune/tune.c | 3 +-- 7 files changed, 7 insertions(+), 11 deletions(-) diff --git a/dump/dump.c b/dump/dump.c index 73a231a..7e30f34 100644 --- a/dump/dump.c +++ b/dump/dump.c @@ -247,8 +247,7 @@ int main(int argc, char *argv[]) if (argc < 2) usage(); - memset(ui.dev_name, 0, sizeof(ui.dev_name)); - snprintf(ui.dev_name, sizeof(ui.dev_name), "%s", argv[1]); + ui.dev_name = argv[1]; ret = exfat_get_blk_dev_info(&ui, &bd); if (ret < 0) diff --git a/exfat2img/exfat2img.c b/exfat2img/exfat2img.c index bd9db44..e75b42f 100644 --- a/exfat2img/exfat2img.c +++ b/exfat2img/exfat2img.c @@ -926,7 +926,7 @@ int main(int argc, char * const argv[]) } memset(&ui, 0, sizeof(ui)); - snprintf(ui.dev_name, sizeof(ui.dev_name), "%s", blkdev_path); + ui.dev_name = blkdev_path; if (restore) ui.writeable = true; else diff --git a/fsck/fsck.c b/fsck/fsck.c index fe8a122..7cac445 100644 --- a/fsck/fsck.c +++ b/fsck/fsck.c @@ -1616,7 +1616,7 @@ int main(int argc, char * const argv[]) exfat_fsck.options = ui.options; - snprintf(ui.ei.dev_name, sizeof(ui.ei.dev_name), "%s", argv[optind]); + ui.ei.dev_name = argv[optind]; ret = exfat_get_blk_dev_info(&ui.ei, &bd); if (ret < 0) { exfat_err("failed to open %s. %d\n", ui.ei.dev_name, ret); diff --git a/include/libexfat.h b/include/libexfat.h index 2ed9aa7..06b5498 100644 --- a/include/libexfat.h +++ b/include/libexfat.h @@ -78,7 +78,7 @@ struct exfat_blk_dev { }; struct exfat_user_input { - char dev_name[255]; + const char *dev_name; bool writeable; unsigned int sector_size; unsigned int cluster_size; diff --git a/label/label.c b/label/label.c index 2780143..c5eea7a 100644 --- a/label/label.c +++ b/label/label.c @@ -81,8 +81,7 @@ int main(int argc, char *argv[]) if (argc < 2) usage(); - memset(ui.dev_name, 0, sizeof(ui.dev_name)); - snprintf(ui.dev_name, sizeof(ui.dev_name), "%s", argv[serial_mode + 1]); + ui.dev_name = argv[serial_mode + 1]; ret = exfat_get_blk_dev_info(&ui, &bd); if (ret < 0) diff --git a/mkfs/mkfs.c b/mkfs/mkfs.c index f9286c1..71f2b10 100644 --- a/mkfs/mkfs.c +++ b/mkfs/mkfs.c @@ -737,8 +737,7 @@ int main(int argc, char *argv[]) goto out; } - memset(ui.dev_name, 0, sizeof(ui.dev_name)); - snprintf(ui.dev_name, sizeof(ui.dev_name), "%s", argv[optind]); + ui.dev_name = argv[optind]; ret = exfat_get_blk_dev_info(&ui, &bd); if (ret < 0) diff --git a/tune/tune.c b/tune/tune.c index 4966e0a..218e840 100644 --- a/tune/tune.c +++ b/tune/tune.c @@ -118,8 +118,7 @@ int main(int argc, char *argv[]) if (argc < 3) usage(); - memset(ui.dev_name, 0, sizeof(ui.dev_name)); - snprintf(ui.dev_name, sizeof(ui.dev_name), "%s", argv[argc - 1]); + ui.dev_name = argv[argc - 1]; ret = exfat_get_blk_dev_info(&ui, &bd); if (ret < 0)