Enlightenment CVS committal Author : xcomputerman Project : e17 Module : apps/e_utils
Dir : e17/apps/e_utils/src/bin/e17genmenu Modified Files: order.c parse.c Log Message: Numerous bugfixes relating to string/list pointer handling. Hopefully most SEGVs and aborts have been eliminated. Primary bugs were attempting to free a substring returned from functions such as strstr() and strrchr(), and missing NULL pointer checks. =================================================================== RCS file: /cvs/e/e17/apps/e_utils/src/bin/e17genmenu/order.c,v retrieving revision 1.1 retrieving revision 1.2 diff -u -3 -r1.1 -r1.2 --- order.c 7 Mar 2006 21:58:24 -0000 1.1 +++ order.c 5 Jul 2006 02:54:42 -0000 1.2 @@ -8,6 +8,8 @@ { char *tmp; + if (!search) return 0; + if (!list) return 0; ecore_list_goto_first(list); while ((tmp = (char *)ecore_list_next(list)) != NULL) { =================================================================== RCS file: /cvs/e/e17/apps/e_utils/src/bin/e17genmenu/parse.c,v retrieving revision 1.8 retrieving revision 1.9 diff -u -3 -r1.8 -r1.9 --- parse.c 30 Jun 2006 00:50:27 -0000 1.8 +++ parse.c 5 Jul 2006 02:54:42 -0000 1.9 @@ -10,6 +10,7 @@ static void _parse_desktop_del(Desktop * desktop); +#if 0 char * get_t(char *icon) { @@ -38,22 +39,24 @@ free(ptr); return strdup(dir); } +#endif char * parse_buffer(char *b, char *section) { - char *oldtoken, *token, *d; - char t[MAX_PATH], p[MAX_PATH]; - int length, i; + char *oldtoken, *token, *substr, *substr2, *str_ret; oldtoken = strdup(b); - token = strstr(oldtoken, section); + substr = strstr(oldtoken, section); - if (token == NULL) + if (substr == NULL) return NULL; - token = strstr(token, "="); - token = strtok(token, "="); + substr2 = strstr(substr, "="); + if (!substr2) return NULL; + if (*(++substr2) == '\0') return NULL; + token = strtok(substr2, "\""); +#if 0 snprintf(t, sizeof(t), "%s", token); d = strrchr(t, '\\'); @@ -89,14 +92,13 @@ { snprintf(p, sizeof(p), "%s", t); } +#endif - if (token) - free(token); + str_ret = strdup(token); + if (oldtoken) free(oldtoken); - if (d) - free(d); - return strdup(p); + return str_ret; } void @@ -245,6 +247,7 @@ if (ecore_file_is_dir(file)) return; + memset(buffer, 0, sizeof(buffer)); overwrite = get_overwrite(); #ifdef DEBUG @@ -267,40 +270,48 @@ if (!(*buffer) || (*buffer == '\n')) continue; /* Strip New Line Chars */ - if (buffer[(length = strlen(buffer) - 1)] == '\n') - buffer[length] = '\0'; + length = strlen(buffer); + if (buffer[length - 1] == '\n') + buffer[length - 1] = '\0'; if (strstr(buffer, "title")) { - name = parse_buffer(strdup(buffer), "title="); + name = parse_buffer(buffer, "title="); eap->name = strdup(name); } if (strstr(buffer, "longtitle")) { - generic = parse_buffer(strdup(buffer), "longtitle="); + generic = parse_buffer(buffer, "longtitle="); eap->generic = strdup(generic); } if (strstr(buffer, "description")) { - comment = parse_buffer(strdup(buffer), "description="); + comment = parse_buffer(buffer, "description="); eap->comment = strdup(comment); } if (strstr(buffer, "section")) { - category = parse_buffer(strdup(buffer), "section="); + category = parse_buffer(buffer, "section="); eap->categories = strdup(category); } if (strstr(buffer, "command")) { - exec = parse_buffer(strdup(buffer), "command="); + exec = parse_buffer(buffer, "command="); eap->exec = strdup(exec); } if (strstr(buffer, "icon")) { - icon = parse_buffer(strdup(buffer), "icon="); - eap->icon = strdup(icon); + icon = parse_buffer(buffer, "icon128x128"); + if (!icon) icon = parse_buffer(buffer, "icon96x96"); + if (!icon) icon = parse_buffer(buffer, "icon48x48"); + if (!icon) icon = parse_buffer(buffer, "icon32x32"); + if (!icon) icon = parse_buffer(buffer, "icon"); + if (icon) + eap->icon = strdup(icon); + else + eap->icon = NULL; } } - buffer[0] = (char)0; + buffer[0] = '\0'; fclose(f); Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 _______________________________________________ enlightenment-cvs mailing list enlightenment-cvs@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs