summaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
authorMiika Pekkarinen <miipekk@ihme.org>2006-05-27 11:21:08 +0000
committerMiika Pekkarinen <miipekk@ihme.org>2006-05-27 11:21:08 +0000
commit196b770a96920e93dff514b9173d290bf73d0a81 (patch)
treef8a972d7892fb2f152dc8d58a37f6dc7d41c7109 /apps
parent45975987b2a18b607c35e05aa7090f102246fdcc (diff)
downloadrockbox-196b770a96920e93dff514b9173d290bf73d0a81.tar.gz
rockbox-196b770a96920e93dff514b9173d290bf73d0a81.tar.bz2
rockbox-196b770a96920e93dff514b9173d290bf73d0a81.zip
Init dircache after applying settings and use a splash. Possible prevent
some type of buffer overflow with tagcache. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@9997 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps')
-rw-r--r--apps/main.c37
-rw-r--r--apps/tagcache.c4
2 files changed, 18 insertions, 23 deletions
diff --git a/apps/main.c b/apps/main.c
index 84c77ab1c9..3878e3a9c4 100644
--- a/apps/main.c
+++ b/apps/main.c
@@ -106,33 +106,25 @@ void init_dircache(void)
int font_w, font_h;
int result;
char buf[32];
+ bool clear = false;
dircache_init();
if (global_settings.dircache)
{
- /* Print "Scanning disk..." to the display. */
- lcd_getstringsize("A", &font_w, &font_h);
- lcd_putsxy((LCD_WIDTH/2) - ((strlen(str(LANG_DIRCACHE_BUILDING))*font_w)/2),
- LCD_HEIGHT-font_h*3, str(LANG_DIRCACHE_BUILDING));
- lcd_update();
-
- result = dircache_build(global_settings.dircache_size);
- if (result < 0)
+ if (global_settings.dircache_size == 0)
{
- snprintf(buf, sizeof(buf),
- "Failed! Result: %d",
- result);
- lcd_getstringsize("A", &font_w, &font_h);
- lcd_putsxy((LCD_WIDTH/2) - ((strlen(buf)*font_w)/2),
- LCD_HEIGHT-font_h*2, buf);
+ gui_syncsplash(0, true, str(LANG_DIRCACHE_BUILDING));
+ clear = true;
}
- else
+
+ result = dircache_build(global_settings.dircache_size);
+ if (result < 0)
+ gui_syncsplash(0, true, "Failed! Result: %d", result);
+
+ if (clear)
{
- /* Clean the text when we are done. */
- lcd_set_drawmode(DRMODE_SOLID|DRMODE_INVERSEVID);
- lcd_fillrect(0, LCD_HEIGHT-font_h*3, LCD_WIDTH, font_h);
- lcd_set_drawmode(DRMODE_SOLID);
- lcd_update();
+ backlight_on();
+ show_logo();
}
}
}
@@ -170,7 +162,10 @@ void init_tagcache(void)
tagtree_init();
if (clear)
+ {
+ backlight_on();
show_logo();
+ }
}
#ifdef SIMULATOR
@@ -389,9 +384,9 @@ void init(void)
settings_load(SETTINGS_ALL);
- init_dircache();
gui_sync_wps_init();
settings_apply();
+ init_dircache();
init_tagcache();
status_init();
diff --git a/apps/tagcache.c b/apps/tagcache.c
index 127c6aa63a..f4e139aafa 100644
--- a/apps/tagcache.c
+++ b/apps/tagcache.c
@@ -1427,7 +1427,6 @@ static int build_index(int index_type, struct tagcache_header *h, int tmpfd)
tempbufidx = 0;
tempbuf_pos = TAGFILE_MAX_ENTRIES * sizeof(struct tempbuf_searchidx);
- memset(tempbuf+tempbuf_pos, 0, LOOKUP_BUF_DEPTH * sizeof(void **));
tempbuf_pos += LOOKUP_BUF_DEPTH * sizeof(void **);
tempbuf_left = tempbuf_size - tempbuf_pos - 8;
if (tempbuf_left - TAGFILE_ENTRY_AVG_LENGTH * TAGFILE_MAX_ENTRIES < 0)
@@ -1438,6 +1437,7 @@ static int build_index(int index_type, struct tagcache_header *h, int tmpfd)
lookup = (struct tempbuf_searchidx **)
(tempbuf + sizeof(struct tempbuf_searchidx)*TAGFILE_MAX_ENTRIES);
+ memset(lookup, 0, LOOKUP_BUF_DEPTH * sizeof(void **));
/* Open the index file, which contains the tag names. */
snprintf(buf, sizeof buf, TAGCACHE_FILE_INDEX, index_type);
@@ -2024,7 +2024,7 @@ static bool allocate_tagcache(void)
sizeof(struct ramcache_header) + TAG_COUNT*sizeof(void *);
logf("tagcache: %d bytes allocated.", stat.ramcache_allocated);
logf("at: 0x%04x", audiobuf);
- audiobuf += (long)((stat.ramcache_allocated & ~0x03) + 0x04);
+ audiobuf += (long)((stat.ramcache_allocated & ~0x03) + 128);
return true;
}