aboutsummaryrefslogtreecommitdiff
path: root/fs
diff options
context:
space:
mode:
authorHeinrich Schuchardt <heinrich.schuchardt@canonical.com>2023-07-26 10:33:13 +0200
committerTom Rini <trini@konsulko.com>2023-08-03 15:30:53 -0400
commit42cd759a371acb49538344dbdb0bf9a8bbb798a0 (patch)
treeae534b7746df6d94d7b49dfc663c43c5f84da7ea /fs
parente205fbcea0b4c94fad4ec04ebf8340fd11f80031 (diff)
downloadu-boot-42cd759a371acb49538344dbdb0bf9a8bbb798a0.zip
u-boot-42cd759a371acb49538344dbdb0bf9a8bbb798a0.tar.gz
u-boot-42cd759a371acb49538344dbdb0bf9a8bbb798a0.tar.bz2
fat: correct sign for deletion mark
The FAT file systems uses character '\xe5' to mark a deleted directory entry. If a file name starts with this character, it is substituted by '\x05' in the directory entry. While (signed char)'\xe5' is a negative number 0xe5 is a positive integer number. We therefore have define a constant DELETED_MARK which matches the signedness of the characters in the directory entry. Correct a comparison where we used the constant 0xe5 with the wrong sign. Use the constant aRING instead of 0x05 like in the rest of the code. Reported-by: Dan Carpenter <dan.carpenter@linaro.org> Fixes: 57b745e2387a ("fs: fat: call set_name() only once") Fixes: 28cef9ca2e86 ("fs: fat: create correct short names") Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com> Reviewed-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'fs')
-rw-r--r--fs/fat/fat_write.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/fs/fat/fat_write.c b/fs/fat/fat_write.c
index e2a9913..a629441 100644
--- a/fs/fat/fat_write.c
+++ b/fs/fat/fat_write.c
@@ -132,9 +132,9 @@ static int set_name(fat_itr *itr, const char *filename, char *shortname)
return period_location;
if (*dirent.name == ' ')
*dirent.name = '_';
- /* 0xe5 signals a deleted directory entry. Replace it by 0x05. */
- if (*dirent.name == 0xe5)
- *dirent.name = 0x05;
+ /* Substitute character 0xe5 signaling deletetion by character 0x05 */
+ if (*dirent.name == DELETED_FLAG)
+ *dirent.name = aRING;
/* If filename and short name are the same, quit. */
sprintf(buf, "%.*s.%.3s", period_location, dirent.name, dirent.ext);