Index: branches/cparm/CHANGES =================================================================== --- branches/cparm/CHANGES (revision 2066) +++ branches/cparm/CHANGES (revision 2067) @@ -1,3 +1,5 @@ +- Security fixes + - Few security fixes - Fixed a serious bug in picopng - Fixed a bug in gui.c, related to the images loading Index: branches/cparm/i386/libsaio/platform.c =================================================================== --- branches/cparm/i386/libsaio/platform.c (revision 2066) +++ branches/cparm/i386/libsaio/platform.c (revision 2067) @@ -359,8 +359,8 @@ HASH_ITER(hh, platform_env, current_var, tmp) { HASH_DEL(platform_env,current_var); if (current_var->name) free(current_var->name); - free(current_var); } + free(current_var); } } Index: branches/cparm/i386/libsaio/CoreHash.h =================================================================== --- branches/cparm/i386/libsaio/CoreHash.h (revision 2066) +++ branches/cparm/i386/libsaio/CoreHash.h (revision 2067) @@ -194,14 +194,14 @@ static void HObj##_DeleteAll(struct HObj *container ) { \ struct HObj *current_var, *tmp; \ \ - if (setjmp(uterror) == -1) { \ + if (setjmp(uterror) == -1) { \ return; \ } else { \ HASH_ITER(hh, container, current_var, tmp) { \ - HASH_DEL(container,current_var); \ - if (current_var->name) free(current_var->name); \ - free(current_var); \ - } \ + HASH_DEL(container,current_var); \ + if (current_var->name) free(current_var->name); \ + } \ + free(current_var); \ } \ } Index: branches/cparm/i386/modules/GUI/gui.c =================================================================== --- branches/cparm/i386/modules/GUI/gui.c (revision 2066) +++ branches/cparm/i386/modules/GUI/gui.c (revision 2067) @@ -48,7 +48,9 @@ static config_file_t themeConfig; // theme.plist -themeList_t* themeList = NULL; +// CoreHash Declarations +__CHNewStrVar(themeList_t) +CHUnInit(themeList_t) static void (*showHelp)(void) = NULL; static char *(*getMemoryInfoString)(void) = NULL; @@ -63,6 +65,11 @@ #define THEME_NAME_DEFAULT "Default" const char* theme_name = THEME_NAME_DEFAULT; +#define MAX_THEMES 255 + +struct themeList_t *gthemeList = NULL; +static char tmp_theme[64]; // should be engouth + char dirsrc[22]; #ifdef EMBED_THEME @@ -1041,45 +1048,34 @@ gui.screen.font_console_color = (color & 0x00FFFFFF); } -#define MAX_THEMES 255 +static void add_theme(const char *theme, uint8_t nb) +{ + struct themeList_t *new_theme; + + new_theme = themeList_t_NewStrVar(theme, >hemeList); + if (!new_theme) + { + return; + } + new_theme->nb = nb; +} -static void add_theme(const char* theme, uint8_t nb) +static char *get_theme_by_index(uint8_t i) { - - themeList_t* new_theme = malloc(sizeof(themeList_t)); - if (new_theme) - { - new_theme->next = themeList; - - themeList = new_theme; - - new_theme->nb = nb; - new_theme->theme = newString(theme); - } + struct themeList_t *current_theme; + for(current_theme=gthemeList;current_theme;current_theme=(struct themeList_t*)(current_theme->hh.next)) + { + if (current_theme->nb == i) + return current_theme->name; + } + return NULL; } -static void free_theme_list() +static void free_theme_list(void) { - themeList_t* entry = themeList; - while(entry) - { -#if DEBUG_GUI - printf("freeing %s (nb = %d)\n", entry->theme, entry->nb); -#endif - - char *theme = entry->theme; - themeList_t* tmp = NULL; - - tmp = entry; - entry = entry->next; - - free(theme); - free(tmp); - - } + themeList_t_DeleteAll(gthemeList); } - static int randomTheme(char *dirspec, const char **theme) { long ret, flags, time; @@ -1105,16 +1101,18 @@ i++; - } + } + #if DEBUG_GUI - themeList_t* debugentry = themeList; - printf("theme list: \n"); - while(debugentry) - { - printf("* %s (nb = %d)\n", debugentry->theme, debugentry->nb); - debugentry = debugentry->next; - } - printf("\n"); + printf("theme list: \n"); + printf("\n"); + struct themeList_t *current_theme; + for(current_theme=gthemeList;current_theme;current_theme=(struct themeList_t*)(current_theme->hh.next)) + { + printf("* %s (nb = %d)\n", current_theme->name, current_theme->nb); + + } + #endif if (i) { @@ -1122,38 +1120,34 @@ uint8_t choosen = arc4random_uniform(i); #if DEBUG_GUI printf("choosen number (nb = %d), i = %d \n", choosen, i); -#endif - themeList_t* entry = themeList; - - while(entry) +#endif + + char *tmp = get_theme_by_index(choosen); + + if (tmp) { - - if (entry->nb == choosen) { -#if DEBUG_GUI - - printf("choosen theme %s (nb = %d)\n", entry->theme, entry->nb); - sleep(1); -#endif - *theme = entry->theme; - - sta = startGUI(); - - break; - } - - entry = entry->next; - } + bzero(tmp_theme,sizeof(tmp_theme)); + strlcpy(tmp_theme, tmp, sizeof(tmp_theme)); + } free_theme_list(); + if (tmp_theme[0]) + { + *theme = tmp_theme; + + sta = startGUI(); + } } + else + { #if DEBUG_GUI - else { printf("No theme found !!\n"); - sleep(1); - } #endif + free_theme_list(); + + } return sta; } Index: branches/cparm/i386/modules/GUI/gui.h =================================================================== --- branches/cparm/i386/modules/GUI/gui.h (revision 2066) +++ branches/cparm/i386/modules/GUI/gui.h (revision 2067) @@ -18,7 +18,7 @@ #include "bootstruct.h" #include "graphic_utils.h" #include "picopng.h" -//#include "options.h" +#include "CoreHash.h" int GUI_initGraphicsMode (void); int GUI_countdown( const char * msg, int row, int timeout , int *optionKey); @@ -56,9 +56,8 @@ typedef struct themeList_t { - char* theme; - unsigned char nb; - struct themeList_t* next; + CoreHashHeader + unsigned char nb; } themeList_t; /* Index: branches/cparm/xcode3_sym.zip =================================================================== Cannot display: file marked as a binary type. svn:mime-type = application/octet-stream