diff options
| author | William Wilgus <me.theuser@yahoo.com> | 2018-07-25 19:28:25 +0200 |
|---|---|---|
| committer | William Wilgus <me.theuser@yahoo.com> | 2018-07-25 19:33:52 +0200 |
| commit | 5e5ddce270ce8fb87baff7ce898173fe2ae2fb6b (patch) | |
| tree | a45e6b40c3f1fc2ef59bd416d5f6d54eca026a6a /apps | |
| parent | 7bec71368b306657323d80585019bb7e2aa0888c (diff) | |
| download | rockbox-5e5ddce270ce8fb87baff7ce898173fe2ae2fb6b.zip rockbox-5e5ddce270ce8fb87baff7ce898173fe2ae2fb6b.tar.gz rockbox-5e5ddce270ce8fb87baff7ce898173fe2ae2fb6b.tar.bz2 rockbox-5e5ddce270ce8fb87baff7ce898173fe2ae2fb6b.tar.xz | |
Fix truncation warnings in tree.c, filetree.c
Change-Id: Ic5ae1e5f904a3da4bba07cdef7f4bb003dc091b2
Diffstat (limited to 'apps')
| -rw-r--r-- | apps/filetree.c | 7 | ||||
| -rw-r--r-- | apps/tree.c | 8 |
2 files changed, 13 insertions, 2 deletions
diff --git a/apps/filetree.c b/apps/filetree.c index 64283b2..79ea1eb 100644 --- a/apps/filetree.c +++ b/apps/filetree.c @@ -436,9 +436,14 @@ int ft_enter(struct tree_context* c) char buf[MAX_PATH]; struct entry* file = tree_get_entry_at(c, c->selected_item); int file_attr = file->attr; + int len; if (c->currdir[1]) - snprintf(buf,sizeof(buf),"%s/%s",c->currdir, file->name); + { + len = snprintf(buf,sizeof(buf),"%s/%s",c->currdir, file->name); + if ((unsigned) len > sizeof(buf)) + splash(HZ, ID2P(LANG_PLAYLIST_ACCESS_ERROR)); + } else snprintf(buf,sizeof(buf),"/%s",file->name); diff --git a/apps/tree.c b/apps/tree.c index e03a494..6b49691 100644 --- a/apps/tree.c +++ b/apps/tree.c @@ -608,6 +608,7 @@ static int dirbrowse(void) { int numentries=0; char buf[MAX_PATH]; + int len; int button; #ifdef HAVE_LCD_BITMAP int oldbutton; @@ -800,8 +801,13 @@ static int dirbrowse(void) attr = entry->attr; if (currdir[1]) /* Not in / */ - snprintf(buf, sizeof buf, "%s/%s", + { + len = snprintf(buf, sizeof buf, "%s/%s", currdir, entry->name); + + if ((unsigned) len > sizeof(buf)) + splash(HZ, ID2P(LANG_PLAYLIST_DIRECTORY_ACCESS_ERROR)); + } else /* In / */ snprintf(buf, sizeof buf, "/%s", entry->name); } |