* add efreet garbage data check

* remove printfs that clutter output
* add efreet file type check - only parse regular files
* chekc mmap returns correctly for MAP_FAILED results
* edje has some stubs for adding script-only objecvts - but nothing useful
right now


SVN revision: 34689
This commit is contained in:
Carsten Haitzler 2008-05-29 02:00:04 +00:00
parent b0f295b1dd
commit 43821d36e4
13 changed files with 2419 additions and 19 deletions

View File

@ -210,6 +210,8 @@ _ecore_fps_debug_init(void)
PROT_READ | PROT_WRITE,
MAP_SHARED,
_ecore_fps_debug_fd, 0);
if (_ecore_fps_runtime_mmap == MAP_FAILED)
_ecore_fps_runtime_mmap = NULL;
}
}

View File

@ -1821,6 +1821,8 @@ _ecore_evas_fps_debug_init(void)
PROT_READ | PROT_WRITE,
MAP_SHARED,
_ecore_evas_fps_debug_fd, 0);
if (_ecore_evas_fps_rendertime_mmap == MAP_FAILED)
_ecore_evas_fps_rendertime_mmap = NULL;
}
}

View File

@ -70,6 +70,7 @@ static void ob_collections(void);
static void ob_collections_group(void);
static void st_collections_group_name(void);
static void st_collections_group_script_only(void);
static void st_collections_group_alias(void);
static void st_collections_group_min(void);
static void st_collections_group_max(void);
@ -192,6 +193,7 @@ New_Statement_Handler statement_handlers[] =
{"collections.color_classes.color_class.color2", st_color_class_color2}, /* dup */
{"collections.color_classes.color_class.color3", st_color_class_color3}, /* dup */
{"collections.group.name", st_collections_group_name},
{"collections.group.script_only", st_collections_group_script_only},
{"collections.group.alias", st_collections_group_alias},
{"collections.group.min", st_collections_group_min},
{"collections.group.max", st_collections_group_max},
@ -763,7 +765,7 @@ st_data_file(void)
}
data = mmap(NULL, buf.st_size, PROT_READ, MAP_SHARED, fd, 0);
if (!data)
if (data == MAP_FAILED)
{
fprintf(stderr, "%s: Error. %s:%i when mapping file \"%s\": \"%s\"\n",
progname, file_in, line, filename, strerror(errno));
@ -1225,6 +1227,28 @@ st_collections_group_name(void)
de->entry = parse_str(0);
}
/**
@page edcref
@property
script_only
@parameters
[on/off]
@effect
The flag (on/off) as to if this group is defined ONLY by script
callbacks such as init(), resize() and shutdown()
@endproperty
*/
static void
st_collections_group_script_only(void)
{
Edje_Part_Collection *pc;
check_arg_count(1);
pc = evas_list_data(evas_list_last(edje_collections));
pc->script_only = parse_bool(0);
}
/**
@page edcref
@property

View File

@ -387,4 +387,5 @@ _edje_edd_setup(void)
EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_collection, Edje_Part_Collection, "prop.max.w", prop.max.w, EET_T_INT);
EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_collection, Edje_Part_Collection, "prop.max.h", prop.max.h, EET_T_INT);
EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_collection, Edje_Part_Collection, "id", id, EET_T_INT);
EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_collection, Edje_Part_Collection, "script_only", id, EET_T_UCHAR);
}

View File

@ -457,6 +457,8 @@ struct _Edje_Part_Collection
Embryo_Program *script; /* all the embryo script code for this group */
const char *part;
unsigned char script_only;
};
struct _Edje_Part

View File

@ -1252,7 +1252,11 @@ eet_open(const char *file, Eet_File_Mode mode)
ef->data_size = file_stat.st_size;
ef->data = mmap(NULL, ef->data_size, PROT_READ,
MAP_SHARED, fileno(ef->fp), 0);
if (ef->data == MAP_FAILED)
{
ef->data = NULL;
return NULL;
}
ef = eet_internal_read(ef);
if (!ef)
return NULL;

View File

@ -12,6 +12,7 @@ test.menu \
test_menu_slash_bad.menu \
entry.png \
entry \
preferences.menu
preferences.menu \
test_garbage
EXTRA_DIST = $(test_DATA)

File diff suppressed because it is too large Load Diff

View File

@ -155,3 +155,20 @@ ef_cb_ini_long_line(void)
if (ini) efreet_ini_free(ini);
return ret;
}
int
ef_cb_ini_garbage(void)
{
Efreet_Ini *ini;
int ret = 1;
ini = efreet_ini_new(PACKAGE_DATA_DIR"/test/test_garbage");
if (!ini)
{
printf("Ini failed to parse.\n");
return 0;
}
if (ini->data) ret = 0;
efreet_ini_free(ini);
return ret;
}

View File

@ -16,6 +16,7 @@ int ef_cb_efreet_icon_theme_list(void);
int ef_cb_efreet_icon_match(void);
int ef_cb_ini_parse(void);
int ef_cb_ini_long_line(void);
int ef_cb_ini_garbage(void);
#if DEFAULT_VISIBILITY
int ef_cb_locale(void);
#endif
@ -53,6 +54,7 @@ static Efreet_Test tests[] = {
{"Icon Matching", ef_cb_efreet_icon_match},
{"INI Parsing", ef_cb_ini_parse},
{"INI Long Line Parsing", ef_cb_ini_long_line},
{"INI Garbage Parsing", ef_cb_ini_garbage},
#if DEFAULT_VISIBILITY
{"Locale Parsing", ef_cb_locale},
#endif

View File

@ -81,7 +81,12 @@ efreet_ini_parse(const char *file)
f = fopen(file, "rb");
if (!f) return NULL;
if (fstat(fileno(f), &file_stat) || file_stat.st_size < 1)
if (fstat(fileno(f), &file_stat) || (file_stat.st_size < 1))
{
fclose(f);
return NULL;
}
if (!S_ISREG(file_stat.st_mode)) /* if not a regular file - close */
{
fclose(f);
return NULL;
@ -89,7 +94,7 @@ efreet_ini_parse(const char *file)
left = file_stat.st_size;
buffer = mmap(NULL, left, PROT_READ, MAP_SHARED, fileno(f), 0);
if (!buffer)
if (buffer == MAP_FAILED)
{
fclose(f);
return NULL;
@ -107,7 +112,7 @@ efreet_ini_parse(const char *file)
/* find the end of line */
for (line_length = 0;
(line_length < left) &&
(line_start[line_length] != '\n'); ++line_length)
(line_start[line_length] != '\n'); line_length++)
;
/* check for all white space */
@ -151,8 +156,8 @@ efreet_ini_parse(const char *file)
ecore_hash_free_value_cb_set(section, ECORE_FREE_CB(free));
old = ecore_hash_remove(data, header);
if (old) printf("[efreet] Warning: duplicate section '%s' "
"in file '%s'\n", header, file);
// if (old) printf("[efreet] Warning: duplicate section '%s' "
// "in file '%s'\n", header, file);
IF_FREE_HASH(old);
ecore_hash_set(data, (void *)ecore_string_instance(header),
@ -162,14 +167,14 @@ efreet_ini_parse(const char *file)
{
/* invalid file - skip line? or refuse to parse file? */
/* just printf for now till we figure out what to do */
printf("Invalid file (%s) (missing ] on group name)\n", file);
// printf("Invalid file (%s) (missing ] on group name)\n", file);
}
goto next_line;
}
if (section == NULL)
{
printf("Invalid file (%s) (missing section)\n", file);
// printf("Invalid file (%s) (missing section)\n", file);
goto next_line;
}
@ -212,7 +217,7 @@ efreet_ini_parse(const char *file)
if (key_end == 0)
{
/* invalid file... */
printf("Invalid file (%s) (invalid key=value pair)\n", file);
// printf("Invalid file (%s) (invalid key=value pair)\n", file);
goto next_line;
}
@ -234,17 +239,16 @@ efreet_ini_parse(const char *file)
ecore_hash_set(section, (void *)ecore_string_instance(key),
efreet_ini_unescape(value));
}
else
{
/* invalid file... */
printf("Invalid file (%s) (missing = from key=value pair)\n", file);
}
// else
// {
// /* invalid file... */
// printf("Invalid file (%s) (missing = from key=value pair)\n", file);
// }
next_line:
left -= line_length + 1;
line_start += line_length + 1;
}
munmap((char*) buffer, file_stat.st_size);
fclose(f);

View File

@ -826,7 +826,7 @@ efreet_mime_shared_mimeinfo_magic_load(const char *file)
if (fd == -1) return;
data = mmap(NULL, size, PROT_READ, MAP_SHARED, fd, 0);
if (data == (void *)-1)
if (data == MAP_FAILED)
{
close(fd);
return;

View File

@ -535,7 +535,7 @@ fb_postinit(FB_Mode *mode)
mode->mem_offset = (unsigned)(fb_fix.smem_start) & (getpagesize()-1);
mode->mem = (unsigned char *)mmap(NULL, fb_fix.smem_len + mode->mem_offset,
PROT_WRITE | PROT_READ, MAP_SHARED, fb, 0);
if ((intptr_t)mode->mem == -1)
if (mode->mem == MAP_FAILED)
{
perror("mmap");
fb_cleanup();