From: <enl...@li...> - 2005-03-16 19:40:47
|
Enlightenment CVS committal Author : tsauerbeck Project : e17 Module : libs/edje Dir : e17/libs/edje/src/bin Modified Files: edje_cc_sources.c edje_decc.c Log Message: don't hardcode the root filename for decompilation =================================================================== RCS file: /cvsroot/enlightenment/e17/libs/edje/src/bin/edje_cc_sources.c,v retrieving revision 1.12 retrieving revision 1.13 diff -u -3 -r1.12 -r1.13 --- edje_cc_sources.c 11 Jan 2005 02:54:07 -0000 1.12 +++ edje_cc_sources.c 16 Mar 2005 19:40:25 -0000 1.13 @@ -184,7 +184,15 @@ void source_fetch(void) { - source_fetch_file(file_in, "main_edje_source.edc"); + char buf[PATH_MAX] = {0}, *ptr; + + ptr = strrchr(file_in, '/'); + if (ptr) + { + snprintf(buf, sizeof (buf), "%s", ptr + 1); + } + + source_fetch_file(file_in, buf[0] ? buf : file_in); } int =================================================================== RCS file: /cvsroot/enlightenment/e17/libs/edje/src/bin/edje_decc.c,v retrieving revision 1.11 retrieving revision 1.12 diff -u -3 -r1.11 -r1.12 --- edje_decc.c 16 Mar 2005 18:52:34 -0000 1.11 +++ edje_decc.c 16 Mar 2005 19:40:25 -0000 1.12 @@ -24,6 +24,7 @@ int e_file_mkdir(char *dir); int e_file_mkpath(char *path); static int compiler_cmd_is_sane(); +static int root_filename_is_sane(); static void main_help(void) @@ -78,12 +79,18 @@ } srcfiles = source_load(ef); - if (!srcfiles) + if (!srcfiles || !srcfiles->list) { printf("ERROR: %s has no decompile information\n", file_in); eet_close(ef); return 0; } + if (!srcfiles->list->data || !root_filename_is_sane()) + { + printf("ERROR: Invalid root filename: '%s'\n", (char *) srcfiles->list->data); + eet_close(ef); + return 0; + } edje_file = eet_data_read(ef, _edje_edd_edje_file, "edje_file"); if (!edje_file) { @@ -264,6 +271,7 @@ { char out[4096]; FILE *f; + SrcFile *sf = srcfiles->list->data; snprintf(out, sizeof(out), "%s/build.sh", outdir); printf("Output Build Script: %s\n", out); @@ -274,7 +282,7 @@ } f = fopen(out, "w"); fprintf(f, "#!/bin/sh\n"); - fprintf(f, "%s $@ -id . -fd . main_edje_source.edc -o %s.eet\n", edje_file->compiler, outdir); + fprintf(f, "%s $@ -id . -fd . %s -o %s.eet\n", edje_file->compiler, sf->name, outdir); fclose(f); #ifndef WIN32 @@ -358,3 +366,31 @@ return 1; } + +static int +root_filename_is_sane() +{ + SrcFile *sf = srcfiles->list->data; + char *f = sf->name, *ptr; + + if (!f || !*f) + { + return 0; + } + + for (ptr = f; ptr && *ptr; ptr++) + { + /* only allow [a-z][A-Z][0-9]_-./ */ + switch (*ptr) + { + case '_': case '-': case '.': case '/': + break; + default: + if (!isalnum(*ptr)) + { + return 0; + } + } + } + return 1; +} |