]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
fs: fat: avoid out of bounds access warning
authorHeinrich Schuchardt <xypron.glpk@gmx.de>
Mon, 25 Jan 2021 23:04:19 +0000 (00:04 +0100)
committerTom Rini <trini@konsulko.com>
Fri, 29 Jan 2021 15:36:48 +0000 (10:36 -0500)
When copying short name plus extension refer to the encapsulating structure
and not to the short name element.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
fs/fat/fat_write.c

index 0132ef9b42f0b6aff795760371c288507800ab66..aae3a6a3d18ccfd567d45ff6c8016d9c59c4c5d2 100644 (file)
@@ -108,10 +108,7 @@ static int set_name(fat_itr *itr, const char *filename, char *shortname)
        char buf[13];
        int i;
        int ret;
-       struct {
-               char name[8];
-               char ext[3];
-       } dirent;
+       struct nameext dirent;
 
        if (!filename)
                return -EIO;
@@ -185,7 +182,7 @@ static int set_name(fat_itr *itr, const char *filename, char *shortname)
        }
        return -EIO;
 out:
-       memcpy(shortname, dirent.name, SHORT_NAME_SIZE);
+       memcpy(shortname, &dirent, SHORT_NAME_SIZE);
        return ret;
 }