Skip to content

Commit

Permalink
exfatprogs: remove the limitation that the device path length cannot …
Browse files Browse the repository at this point in the history
…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 <[email protected]>
Reviewed-by: Aoyama Wataru <[email protected]>
  • Loading branch information
YuezhangMo committed Jul 11, 2024
1 parent 9091dff commit 9e40f4f
Show file tree
Hide file tree
Showing 7 changed files with 7 additions and 11 deletions.
3 changes: 1 addition & 2 deletions dump/dump.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion exfat2img/exfat2img.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion fsck/fsck.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion include/libexfat.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
3 changes: 1 addition & 2 deletions label/label.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
3 changes: 1 addition & 2 deletions mkfs/mkfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
3 changes: 1 addition & 2 deletions tune/tune.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 9e40f4f

Please sign in to comment.