mirror of
https://github.com/Rockbox/rockbox.git
synced 2025-10-14 02:27:39 -04:00
[BugFix] tagcache.c fix off by one error in find_entry_disk()
the tagcache counts the null terminator strlen however, does not no matching entries makes for a terrible amount of disk searching and a hang on devices without dircache to save them Change-Id: Id3460037199ee9853de0f11e4763a7ff11130e45
This commit is contained in:
parent
c955d93075
commit
d5a84d42b0
1 changed files with 7 additions and 4 deletions
|
@ -707,7 +707,7 @@ static long find_entry_disk(const char *filename_raw, bool localfd)
|
||||||
else /* start back at beginning */
|
else /* start back at beginning */
|
||||||
pos = lseek(fd, sizeof(struct tagcache_header), SEEK_SET);
|
pos = lseek(fd, sizeof(struct tagcache_header), SEEK_SET);
|
||||||
|
|
||||||
long tag_length = strlen(filename);
|
long tag_length = strlen(filename) + 1; /* include NULL */
|
||||||
|
|
||||||
if (tag_length < bufsz)
|
if (tag_length < bufsz)
|
||||||
{
|
{
|
||||||
|
@ -724,6 +724,7 @@ static long find_entry_disk(const char *filename_raw, bool localfd)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
pos += sizeof(struct tagfile_entry) + tfe.tag_length;
|
||||||
/* don't read the entry unless the length matches */
|
/* don't read the entry unless the length matches */
|
||||||
if (tfe.tag_length == tag_length)
|
if (tfe.tag_length == tag_length)
|
||||||
{
|
{
|
||||||
|
@ -744,7 +745,9 @@ static long find_entry_disk(const char *filename_raw, bool localfd)
|
||||||
break ;
|
break ;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
pos += sizeof(struct tagfile_entry) + tfe.tag_length;
|
else
|
||||||
|
lseek(fd, pos, SEEK_SET);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (pos_history_idx < POS_HISTORY_COUNT - 1)
|
if (pos_history_idx < POS_HISTORY_COUNT - 1)
|
||||||
|
@ -4521,7 +4524,7 @@ static bool check_file_refs(bool auto_update)
|
||||||
ret = false;
|
ret = false;
|
||||||
goto wend_finished;
|
goto wend_finished;
|
||||||
case e_ENTRY_SIZEMISMATCH:
|
case e_ENTRY_SIZEMISMATCH:
|
||||||
logf("size mismatch entry");
|
logf("size mismatch entry EOF?"); /* likely EOF */
|
||||||
ret = false;
|
ret = false;
|
||||||
goto wend_finished;
|
goto wend_finished;
|
||||||
case e_TAG_TOOLONG:
|
case e_TAG_TOOLONG:
|
||||||
|
@ -4564,7 +4567,7 @@ static bool check_file_refs(bool auto_update)
|
||||||
}
|
}
|
||||||
else if (rc_cache == 0) /* not in cache but okay */
|
else if (rc_cache == 0) /* not in cache but okay */
|
||||||
{;}
|
{;}
|
||||||
else if (auto_update)
|
else if (auto_update && rc_cache == ENOENT)
|
||||||
#else
|
#else
|
||||||
if (!file_exists(buf))
|
if (!file_exists(buf))
|
||||||
#endif /* HAVE_DIRCACHE */
|
#endif /* HAVE_DIRCACHE */
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue