diff options
author | William Wilgus <wilgus.william@gmail.com> | 2024-06-02 10:37:25 -0400 |
---|---|---|
committer | William Wilgus <me.theuser@yahoo.com> | 2024-06-02 10:41:50 -0400 |
commit | 5c7fbe8f1b5d78bf03c98d72a18ca13e74261e7b (patch) | |
tree | e5576eb3cc4ff0efcd668ce94959f2640e76249e /apps | |
parent | cc67f420f215481ef41ed2bc228fb2b28f7eeb80 (diff) | |
download | rockbox-5c7fbe8f1b5d78bf03c98d72a18ca13e74261e7b.tar.gz rockbox-5c7fbe8f1b5d78bf03c98d72a18ca13e74261e7b.zip |
[coverity] tree.c set_current_file_ex explicitly check strrchr output
the math
size_t endpos = filename - path;
if (filename && endpos < MAX_PATH - 1)
should handle it just fine coverity doesn't think so
Change-Id: Ifa0494e56b40c8ab0081ebc771024a45cb24eb76
Diffstat (limited to 'apps')
-rw-r--r-- | apps/tree.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/apps/tree.c b/apps/tree.c index f40e6eaa2a..d9d23d277a 100644 --- a/apps/tree.c +++ b/apps/tree.c | |||
@@ -621,7 +621,7 @@ static void set_current_file_ex(const char *path, const char *filename) | |||
621 | /* gets the directory's name and put it into tc.currdir */ | 621 | /* gets the directory's name and put it into tc.currdir */ |
622 | filename = strrchr(path+1,'/'); | 622 | filename = strrchr(path+1,'/'); |
623 | size_t endpos = filename - path; | 623 | size_t endpos = filename - path; |
624 | if (endpos < MAX_PATH - 1) | 624 | if (filename && endpos < MAX_PATH - 1) |
625 | { | 625 | { |
626 | strmemccpy(tc.currdir, path, endpos + 1); | 626 | strmemccpy(tc.currdir, path, endpos + 1); |
627 | filename++; | 627 | filename++; |
@@ -1039,7 +1039,7 @@ int rockbox_browse(struct browse_context *browse) | |||
1039 | { | 1039 | { |
1040 | tc.is_browsing = (browse != NULL); | 1040 | tc.is_browsing = (browse != NULL); |
1041 | int ret_val = 0; | 1041 | int ret_val = 0; |
1042 | int dirfilter = browse->dirfilter; | 1042 | int dirfilter = tc.is_browsing ? browse->dirfilter : SHOW_ALL; |
1043 | 1043 | ||
1044 | if (backup_count >= NUM_TC_BACKUP) | 1044 | if (backup_count >= NUM_TC_BACKUP) |
1045 | return GO_TO_PREVIOUS; | 1045 | return GO_TO_PREVIOUS; |