From 4469165e8af2c55e212c65935b139298725ba8b2 Mon Sep 17 00:00:00 2001 From: penfold42 Date: Mon, 30 Jul 2018 20:04:54 +1000 Subject: [PATCH 1/2] Add ' R' to readonly file in filebrowser oled display --- src/FileBrowser.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/FileBrowser.cpp b/src/FileBrowser.cpp index d5918bb..f3049b6 100644 --- a/src/FileBrowser.cpp +++ b/src/FileBrowser.cpp @@ -102,10 +102,17 @@ void FileBrowser::BrowsableListView::RefreshLine(u32 entryIndex, u32 x, u32 y, b } else { + char ROstring[8] = { 0 }; + if (entry->filImage.fattrib & AM_RDO) + strncpy (ROstring, " R", 8); if (entry->caddyIndex != -1) - snprintf(buffer2, 256, "%d>%s", entry->caddyIndex, entry->filImage.fname); + snprintf(buffer2, 256, "%d>%s%s" + , entry->caddyIndex + , entry->filImage.fname + , ROstring + ); else - snprintf(buffer2, 256, "%s", entry->filImage.fname); + snprintf(buffer2, 256, "%s%s", entry->filImage.fname, ROstring); } } else From 0ddf2a6e0ab42eb50b44c8e0d5364b0b2e1ab4b2 Mon Sep 17 00:00:00 2001 From: penfold42 Date: Mon, 30 Jul 2018 22:24:07 +1000 Subject: [PATCH 2/2] In browser on oled, add '<' for readonly files fix potential out by error/buffer overflow --- src/FileBrowser.cpp | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/src/FileBrowser.cpp b/src/FileBrowser.cpp index f3049b6..6768a7e 100644 --- a/src/FileBrowser.cpp +++ b/src/FileBrowser.cpp @@ -88,8 +88,8 @@ void FileBrowser::BrowsableListView::RefreshLine(u32 entryIndex, u32 x, u32 y, b RGBA BkColour = RGBA(0, 0, 0, 0xFF); //palette[VIC2_COLOUR_INDEX_BLUE]; u32 columnsMax = columns; - if (columnsMax > sizeof(buffer1)) - columnsMax = sizeof(buffer1); + if (columnsMax > sizeof(buffer1)-1) + columnsMax = sizeof(buffer1)-1; if (entryIndex < list->entries.size()) { @@ -104,7 +104,7 @@ void FileBrowser::BrowsableListView::RefreshLine(u32 entryIndex, u32 x, u32 y, b { char ROstring[8] = { 0 }; if (entry->filImage.fattrib & AM_RDO) - strncpy (ROstring, " R", 8); + strncpy (ROstring, "<", 8); if (entry->caddyIndex != -1) snprintf(buffer2, 256, "%d>%s%s" , entry->caddyIndex @@ -157,7 +157,7 @@ void FileBrowser::BrowsableListView::RefreshLine(u32 entryIndex, u32 x, u32 y, b } else { - memset(buffer1, ' ', 80); + memset(buffer1, ' ', columnsMax); screen->PrintText(false, x, y, buffer1, BkColour, BkColour); } } @@ -203,10 +203,17 @@ void FileBrowser::BrowsableListView::RefreshHighlightScroll() } else { + char ROstring[8] = { 0 }; + if (entry->filImage.fattrib & AM_RDO) + strncpy (ROstring, "<", 8); if (entry->caddyIndex != -1) - snprintf(buffer2, 256, "%d>%s", entry->caddyIndex, entry->filImage.fname); + snprintf(buffer2, 256, "%d>%s%s" + , entry->caddyIndex + , entry->filImage.fname + , ROstring + ); else - snprintf(buffer2, 256, "%s", entry->filImage.fname); + snprintf(buffer2, 256, "%s%s", entry->filImage.fname, ROstring); } } else