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
This commit is contained in:
Miika Pekkarinen 2006-05-27 11:21:08 +00:00
parent 45975987b2
commit 196b770a96
2 changed files with 18 additions and 23 deletions

View file

@ -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();
if (global_settings.dircache_size == 0)
{
gui_syncsplash(0, true, str(LANG_DIRCACHE_BUILDING));
clear = true;
}
result = dircache_build(global_settings.dircache_size);
if (result < 0)
gui_syncsplash(0, true, "Failed! Result: %d", result);
if (clear)
{
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);
}
else
{
/* 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();

View file

@ -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;
}