diff options
author | William Wilgus <wilgus.william@gmail.com> | 2023-02-04 11:22:31 -0500 |
---|---|---|
committer | William Wilgus <wilgus.william@gmail.com> | 2023-02-04 11:39:43 -0500 |
commit | d5a84d42b020746a4eb6509c984afd0b18ccc16a (patch) | |
tree | d13f9db0453bf70af3ab26fa5b5f97c7cd5b6fce | |
parent | c955d93075a1eaefc409bfa0389769a5353842f3 (diff) | |
download | rockbox-d5a84d42b0.tar.gz rockbox-d5a84d42b0.zip |
[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
-rw-r--r-- | apps/tagcache.c | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/apps/tagcache.c b/apps/tagcache.c index 91fd8817eb..60d82d002b 100644 --- a/apps/tagcache.c +++ b/apps/tagcache.c @@ -707,7 +707,7 @@ static long find_entry_disk(const char *filename_raw, bool localfd) else /* start back at beginning */ 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) { @@ -724,6 +724,7 @@ static long find_entry_disk(const char *filename_raw, bool localfd) } else { + pos += sizeof(struct tagfile_entry) + tfe.tag_length; /* don't read the entry unless the length matches */ if (tfe.tag_length == tag_length) { @@ -744,7 +745,9 @@ static long find_entry_disk(const char *filename_raw, bool localfd) break ; } } - pos += sizeof(struct tagfile_entry) + tfe.tag_length; + else + lseek(fd, pos, SEEK_SET); + } } if (pos_history_idx < POS_HISTORY_COUNT - 1) @@ -4521,7 +4524,7 @@ static bool check_file_refs(bool auto_update) ret = false; goto wend_finished; case e_ENTRY_SIZEMISMATCH: - logf("size mismatch entry"); + logf("size mismatch entry EOF?"); /* likely EOF */ ret = false; goto wend_finished; 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 (auto_update) + else if (auto_update && rc_cache == ENOENT) #else if (!file_exists(buf)) #endif /* HAVE_DIRCACHE */ |