ecrire: arguent load defense
This commit is contained in:
parent
50db48daf5
commit
e5cf942255
|
@ -26,11 +26,18 @@ file_load(const char *file)
|
|||
{
|
||||
FILE *f;
|
||||
size_t size;
|
||||
struct stat st;
|
||||
int alloc = 0, len = 0;
|
||||
char *text = NULL, buf[16384 + 1];
|
||||
|
||||
if (stat(file, &st) != -1)
|
||||
{
|
||||
if (st.st_size == 0) return strdup("");
|
||||
}
|
||||
|
||||
f = fopen(file, "rb");
|
||||
if (!f) return NULL;
|
||||
|
||||
while ((size = fread(buf, 1, sizeof(buf) - 1, f)))
|
||||
{
|
||||
char *tmp_text;
|
||||
|
|
|
@ -344,11 +344,11 @@ _load_to_entry(Ecrire_Entry *inst, const char *file)
|
|||
char *buf;
|
||||
|
||||
if (plain_utf8)
|
||||
buf = file_plain_load(file);
|
||||
buf = file_plain_load(file);
|
||||
else
|
||||
buf = file_load(file);
|
||||
buf = file_load(file);
|
||||
|
||||
if (!buf)
|
||||
if (!buf)
|
||||
ok = 0;
|
||||
else
|
||||
{
|
||||
|
@ -357,7 +357,7 @@ _load_to_entry(Ecrire_Entry *inst, const char *file)
|
|||
elm_entry_entry_append(inst->entry, buf);
|
||||
elm_object_item_disabled_set(inst->save_item, EINA_TRUE);
|
||||
free(buf);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (ok)
|
||||
|
@ -718,7 +718,15 @@ elm_main(int argc, char **argv)
|
|||
|
||||
if (optind < argc)
|
||||
{
|
||||
inst->filename = eina_stringshare_add(argv[optind]);
|
||||
if (!ecore_file_exists(argv[optind]))
|
||||
return 1;
|
||||
char *path = ecore_file_realpath(argv[optind]);
|
||||
if (path)
|
||||
{
|
||||
if (ecore_file_is_dir(argv[optind])) return 1;
|
||||
|
||||
inst->filename = eina_stringshare_add(path);
|
||||
}
|
||||
}
|
||||
|
||||
DBG("Opening filename: '%s'", inst->filename);
|
||||
|
@ -789,6 +797,7 @@ elm_main(int argc, char **argv)
|
|||
|
||||
elm_run();
|
||||
|
||||
eina_stringshare_del(inst->filename);
|
||||
free(inst);
|
||||
|
||||
ecrire_cfg_shutdown();
|
||||
|
|
Loading…
Reference in New Issue