Repository navigation
Prevent NTFS and VFAT labels from being interpreted as options #1220
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -51,7 +51,7 @@ void _fs_vfat_reset_avail_deps (void) { | |
|
|
||
| static const UtilDep deps[DEPS_LAST] = { | ||
| {"mkfs.vfat", NULL, NULL, NULL}, | ||
| {"fatlabel", NULL, NULL, NULL}, | ||
| {"fatlabel", "4.2", "--version", "fatlabel\\s+([\\d\\.]+).+"}, | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Remove the fatlabel 4.2 floor from ordinary label sets.
fatlabel 4.1 accepts only Suggested fix
|
||
| {"fsck.vfat", NULL, NULL, NULL}, | ||
| {"vfat-resize", NULL, NULL, NULL}, | ||
| {"fatlabel", "4.2", "--version", "fatlabel\\s+([\\d\\.]+).+"}, | ||
|
|
@@ -288,33 +288,24 @@ gboolean bd_fs_vfat_repair (const gchar *device, const BDExtraArg **extra, GErro | |
| * Tech category: %BD_FS_TECH_VFAT-%BD_FS_TECH_MODE_SET_LABEL | ||
| */ | ||
| gboolean bd_fs_vfat_set_label (const gchar *device, const gchar *label, GError **error) { | ||
| const gchar *args[4] = {"fatlabel", device, NULL, NULL}; | ||
| UtilDep dep = {"fatlabel", "4.2", "--version", "fatlabel\\s+([\\d\\.]+).+"}; | ||
| gchar *label_up = NULL; | ||
| gboolean new_vfat = FALSE; | ||
| gboolean ret; | ||
| const gchar *args[5] = {"fatlabel", "--", device, label, NULL}; | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| g_autofree gchar *label_up = NULL; | ||
|
|
||
| if (!check_deps (&avail_deps, DEPS_FATLABEL_MASK, deps, DEPS_LAST, &deps_check_lock, error)) | ||
| return FALSE; | ||
|
|
||
| if (!label || g_strcmp0 (label, "") == 0) { | ||
| /* fatlabel >= 4.2 refuses to set empty label */ | ||
| new_vfat = bd_utils_check_util_version (dep.name, dep.version, | ||
| dep.ver_arg, dep.ver_regexp, | ||
| NULL); | ||
| if (new_vfat) | ||
| args[2] = "--reset"; | ||
| } | ||
|
|
||
| /* forcefully convert the label uppercase in case no reset was requested */ | ||
| if (label && args[2] == NULL) { | ||
| /* fatlabel >= 4.2 refuses to set an empty label, use --reset instead */ | ||
| args[1] = "--reset"; | ||
| args[2] = "--"; | ||
| args[3] = device; | ||
| } else { | ||
| /* forcefully convert a non-empty label uppercase */ | ||
| label_up = g_ascii_strup (label, -1); | ||
| args[2] = label_up; | ||
| args[3] = label_up; | ||
| } | ||
| ret = bd_utils_exec_and_report_error (args, NULL, error); | ||
| g_free (label_up); | ||
|
|
||
| return ret; | ||
| return bd_utils_exec_and_report_error (args, NULL, error); | ||
| } | ||
|
|
||
| /** | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Script executed:
Repository: storaged-project/libblockdev
Length of output: 3876
Script executed:
Repository: storaged-project/libblockdev
Length of output: 2232
Web query:
ntfs-3g ntfslabel maximum label length 128 characters UTF-16 code units or bytesResult:
Count NTFS label length in UTF-16 units, not UTF-8 bytes.
bd_fs_ntfs_check_labelmeasures the label withstrlen()and compares the byte count to 128.bd_fs_ntfs_set_labelnow calls this check before it runsntfslabel. A label thatntfslabelaccepts, such as 65écharacters (130 UTF-8 bytes), is rejected. Count UTF-16 code units, asntfslabeldoes, and compare that count to 128.