From: Lawrence S. <ljs...@us...> - 2019-09-09 23:22:59
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "A pseudo Operating System for the Dreamcast.". The branch, master has been updated via 030c480e9a27a58c4aa228c354d85bb15721551f (commit) from b5489497815305c1a174039a853aa6c61ea3a01c (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit 030c480e9a27a58c4aa228c354d85bb15721551f Author: Lawrence Sebald <ljs...@us...> Date: Mon Sep 9 19:22:19 2019 -0400 libkosfat: Fix longname searches that span a block/cluster. ----------------------------------------------------------------------- Summary of changes: addons/libkosfat/directory.c | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/addons/libkosfat/directory.c b/addons/libkosfat/directory.c index 087da76..b9c744e 100644 --- a/addons/libkosfat/directory.c +++ b/addons/libkosfat/directory.c @@ -130,6 +130,8 @@ static int read_longname(fat_fs_t *fs, uint32_t *cluster, uint32_t *offset, fat_longname_t *lent; uint8_t *cl; + ++*offset; + while(!done) { if(!(cl = fat_cluster_read(fs, *cluster, &err))) { dbglog(DBG_ERROR, "Error reading directory at cluster %" PRIu32 @@ -137,7 +139,7 @@ static int read_longname(fat_fs_t *fs, uint32_t *cluster, uint32_t *offset, return -EIO; } - for(i = (*offset) + 1; i < max; ++i) { + for(i = *offset; i < max; ++i) { ent = (fat_dentry_t *)(cl + (i << 5)); /* If name[0] is zero, then we've hit the end of the directory. */ @@ -175,18 +177,24 @@ static int read_longname(fat_fs_t *fs, uint32_t *cluster, uint32_t *offset, if(!(*cluster & 0x80000000)) { *cluster = fat_read_fat(fs, *cluster, &err); - if(*cluster == 0xFFFFFFFF) + if(*cluster == 0xFFFFFFFF) { return -EIO; + } if(fat_is_eof(fs, *cluster)) done = 1; + + *offset = 0; } else { ++*cluster; *max2 -= max; - if(*max2 <= 0) + if(*max2 <= 0) { return -EIO; + } + + *offset = 0; } } @@ -198,12 +206,12 @@ static int fat_search_long(fat_fs_t *fs, const char *fn, uint32_t cluster, uint32_t *rlcl, uint32_t *rloff) { uint8_t *cl; int err, done = 0; - uint32_t i, max, skip = 0; + uint32_t i = 0, max, skip = 0; int32_t max2; fat_dentry_t *ent; fat_longname_t *lent; size_t l = strlen(fn); - uint32_t fnlen, lcl = 0, loff = 0; + uint32_t fnlen, lcl = 0, loff = 0, cluster2; /* Figure out how many directory entries there are in each cluster/block. */ if(fs->sb.fs_type == FAT_FS_FAT32 || !(cluster & 0x80000000)) { @@ -229,7 +237,8 @@ static int fat_search_long(fat_fs_t *fs, const char *fn, uint32_t cluster, return -EIO; } - for(i = 0; i < max && !done; ++i) { + for(; i < max && !done; ++i) { + cluster2 = cluster; ent = (fat_dentry_t *)(cl + (i << 5)); /* Are we skipping this entry? */ @@ -354,8 +363,12 @@ static int fat_search_long(fat_fs_t *fs, const char *fn, uint32_t cluster, return 0; } } - else + else { skip = 1; + + if(cluster2 != cluster) + break; + } } if(!(cluster & 0x80000000)) { hooks/post-receive -- A pseudo Operating System for the Dreamcast. |