Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions components/dfs/dfs_v1/filesystems/iso9660/dfs_iso9660.c
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,12 @@ static struct iso9660_fd *iso9660_lookup(struct iso9660 *iso, const char *path,

namelen = rt_le32_to_cpu(dirent->namelen);

/* The name length comes from the medium, never trust it */
if (namelen >= MAX_NAMELEN)
{
namelen = MAX_NAMELEN - 1;
}

if (iso->joliet)
{
iso9660_convert_string(sname, (rt_uint16_t *)dirent->name, namelen);
Expand All @@ -298,8 +304,11 @@ static struct iso9660_fd *iso9660_lookup(struct iso9660 *iso, const char *path,
{
if (!(rt_le32_to_cpu(dirent->flags) & FLAG_TYPE_DIR))
{
/* Remove ";1" */
namelen -= 2;
/* Remove ";1", but only when the name is long enough */
if (namelen >= 2)
{
namelen -= 2;
}
}

iso9660_convert_lower(sname, (rt_uint8_t *)dirent->name, namelen);
Expand Down
Loading