forked from enlightenment/efl
When using snprintf or fgets, etc, do not use PATH_MAX directly as the size
of the variable...use sizeof() compiler directive (lots of these). Do not free 'realpath' in efreet_menu if we are going to try and print out it's value. If we find 'realpath' in the merged_menus hash, and we are going to return, then free the realpath variable. SVN revision: 44699
This commit is contained in:
parent
005ee7f261
commit
56ec4c946f
|
@ -51,7 +51,7 @@ dump(Efreet_Menu *menu, const char *path)
|
||||||
{
|
{
|
||||||
char new_path[PATH_MAX];
|
char new_path[PATH_MAX];
|
||||||
|
|
||||||
snprintf(new_path, PATH_MAX, "%s%s/", path, entry->name);
|
snprintf(new_path, sizeof(new_path), "%s%s/", path, entry->name);
|
||||||
dump(entry, new_path);
|
dump(entry, new_path);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1666,7 +1666,7 @@ efreet_desktop_command_file_process(Efreet_Desktop_Command *command, const char
|
||||||
{
|
{
|
||||||
char buf[PATH_MAX];
|
char buf[PATH_MAX];
|
||||||
|
|
||||||
snprintf(buf, PATH_MAX, "/tmp/%d-%d-%s", getpid(),
|
snprintf(buf, sizeof(buf), "/tmp/%d-%d-%s", getpid(),
|
||||||
efreet_desktop_command_file_id++, base);
|
efreet_desktop_command_file_id++, base);
|
||||||
f->fullpath = strdup(buf);
|
f->fullpath = strdup(buf);
|
||||||
f->pending = 1;
|
f->pending = 1;
|
||||||
|
|
|
@ -847,7 +847,7 @@ efreet_icon_fallback_icon(const char *icon_name)
|
||||||
|
|
||||||
EINA_LIST_FOREACH(xdg_dirs, l, dir)
|
EINA_LIST_FOREACH(xdg_dirs, l, dir)
|
||||||
{
|
{
|
||||||
snprintf(path, PATH_MAX, "%s/icons", dir);
|
snprintf(path, sizeof(path), "%s/icons", dir);
|
||||||
icon = efreet_icon_fallback_dir_scan(path, icon_name);
|
icon = efreet_icon_fallback_dir_scan(path, icon_name);
|
||||||
if (icon)
|
if (icon)
|
||||||
{
|
{
|
||||||
|
@ -858,7 +858,7 @@ efreet_icon_fallback_icon(const char *icon_name)
|
||||||
|
|
||||||
EINA_LIST_FOREACH(xdg_dirs, l, dir)
|
EINA_LIST_FOREACH(xdg_dirs, l, dir)
|
||||||
{
|
{
|
||||||
snprintf(path, PATH_MAX, "%s/pixmaps", dir);
|
snprintf(path, sizeof(path), "%s/pixmaps", dir);
|
||||||
icon = efreet_icon_fallback_dir_scan(path, icon_name);
|
icon = efreet_icon_fallback_dir_scan(path, icon_name);
|
||||||
if (icon)
|
if (icon)
|
||||||
{
|
{
|
||||||
|
|
|
@ -547,7 +547,7 @@ efreet_menu_kde_legacy_init(void)
|
||||||
|
|
||||||
/* XXX if the return from kde-config is a line longer than PATH_MAX,
|
/* XXX if the return from kde-config is a line longer than PATH_MAX,
|
||||||
* this won't be correct (increase buffer and get the rest...) */
|
* this won't be correct (increase buffer and get the rest...) */
|
||||||
if (!fgets(buf, PATH_MAX, f))
|
if (!fgets(buf, sizeof(buf), f))
|
||||||
{
|
{
|
||||||
ERR("Error initializing KDE legacy information");
|
ERR("Error initializing KDE legacy information");
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -1672,20 +1672,25 @@ efreet_menu_merge(Efreet_Menu_Internal *parent, Efreet_Xml *xml, const char *pat
|
||||||
|
|
||||||
/* don't merge the same path twice */
|
/* don't merge the same path twice */
|
||||||
if (eina_hash_find(efreet_merged_menus, realpath))
|
if (eina_hash_find(efreet_merged_menus, realpath))
|
||||||
|
{
|
||||||
|
FREE(realpath);
|
||||||
return 1;
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
eina_hash_add(efreet_merged_menus, realpath, (void *)1);
|
eina_hash_add(efreet_merged_menus, realpath, (void *)1);
|
||||||
|
|
||||||
merge_xml = efreet_xml_new(realpath);
|
merge_xml = efreet_xml_new(realpath);
|
||||||
FREE(realpath);
|
|
||||||
|
|
||||||
if (!merge_xml)
|
if (!merge_xml)
|
||||||
{
|
{
|
||||||
INF("efreet_menu_merge() failed to read in the "
|
INF("efreet_menu_merge() failed to read in the "
|
||||||
"merge file (%s)", realpath);
|
"merge file (%s)", realpath);
|
||||||
|
FREE(realpath);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
FREE(realpath);
|
||||||
|
|
||||||
internal = efreet_menu_internal_new();
|
internal = efreet_menu_internal_new();
|
||||||
efreet_menu_path_set(internal, path);
|
efreet_menu_path_set(internal, path);
|
||||||
efreet_menu_handle_menu(internal, merge_xml);
|
efreet_menu_handle_menu(internal, merge_xml);
|
||||||
|
@ -1760,7 +1765,7 @@ efreet_menu_merge_dir(Efreet_Menu_Internal *parent, Efreet_Xml *xml, const char
|
||||||
if (!p) continue;
|
if (!p) continue;
|
||||||
if (strcmp(p, ".menu")) continue;
|
if (strcmp(p, ".menu")) continue;
|
||||||
|
|
||||||
snprintf(dir_path, PATH_MAX, "%s/%s", path, file->d_name);
|
snprintf(dir_path, sizeof(dir_path), "%s/%s", path, file->d_name);
|
||||||
if (!efreet_menu_merge(parent, xml, dir_path))
|
if (!efreet_menu_merge(parent, xml, dir_path))
|
||||||
{
|
{
|
||||||
closedir(files);
|
closedir(files);
|
||||||
|
@ -1980,7 +1985,7 @@ efreet_menu_handle_legacy_dir_helper(Efreet_Menu_Internal *root,
|
||||||
|
|
||||||
if (prefix)
|
if (prefix)
|
||||||
{
|
{
|
||||||
snprintf(buf, PATH_MAX, "%s%s", prefix, file->d_name);
|
snprintf(buf, sizeof(buf), "%s%s", prefix, file->d_name);
|
||||||
filter->op->filenames = eina_list_append(filter->op->filenames, strdup(buf));
|
filter->op->filenames = eina_list_append(filter->op->filenames, strdup(buf));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -3420,9 +3425,9 @@ efreet_menu_app_dir_scan(Efreet_Menu_Internal *internal, const char *path, const
|
||||||
while ((file = readdir(files)))
|
while ((file = readdir(files)))
|
||||||
{
|
{
|
||||||
if (!strcmp(file->d_name, ".") || !strcmp(file->d_name, "..")) continue;
|
if (!strcmp(file->d_name, ".") || !strcmp(file->d_name, "..")) continue;
|
||||||
snprintf(buf, PATH_MAX, "%s/%s", path, file->d_name);
|
snprintf(buf, sizeof(buf), "%s/%s", path, file->d_name);
|
||||||
if (id)
|
if (id)
|
||||||
snprintf(buf2, PATH_MAX, "%s-%s", id, file->d_name);
|
snprintf(buf2, sizeof(buf2), "%s-%s", id, file->d_name);
|
||||||
else
|
else
|
||||||
strcpy(buf2, file->d_name);
|
strcpy(buf2, file->d_name);
|
||||||
|
|
||||||
|
@ -3525,9 +3530,9 @@ efreet_menu_directory_dir_scan(const char *path, const char *relative_path,
|
||||||
while ((file = readdir(files)))
|
while ((file = readdir(files)))
|
||||||
{
|
{
|
||||||
if (!strcmp(file->d_name, ".") || !strcmp(file->d_name, "..")) continue;
|
if (!strcmp(file->d_name, ".") || !strcmp(file->d_name, "..")) continue;
|
||||||
snprintf(buf, PATH_MAX, "%s/%s", path, file->d_name);
|
snprintf(buf, sizeof(buf), "%s/%s", path, file->d_name);
|
||||||
if (relative_path)
|
if (relative_path)
|
||||||
snprintf(buf2, PATH_MAX, "%s/%s", relative_path, file->d_name);
|
snprintf(buf2, sizeof(buf2), "%s/%s", relative_path, file->d_name);
|
||||||
else
|
else
|
||||||
strcpy(buf2, file->d_name);
|
strcpy(buf2, file->d_name);
|
||||||
|
|
||||||
|
|
|
@ -651,12 +651,12 @@ efreet_mime_init_files(void)
|
||||||
* We watch the directories so we can watch for new files
|
* We watch the directories so we can watch for new files
|
||||||
*/
|
*/
|
||||||
datadir = datahome;
|
datadir = datahome;
|
||||||
snprintf(buf, PATH_MAX, "%s/mime", datadir);
|
snprintf(buf, sizeof(buf), "%s/mime", datadir);
|
||||||
efreet_mime_monitor_add(buf);
|
efreet_mime_monitor_add(buf);
|
||||||
|
|
||||||
EINA_LIST_FOREACH(datadirs, l, datadir)
|
EINA_LIST_FOREACH(datadirs, l, datadir)
|
||||||
{
|
{
|
||||||
snprintf(buf, PATH_MAX, "%s/mime", datadir);
|
snprintf(buf, sizeof(buf), "%s/mime", datadir);
|
||||||
efreet_mime_monitor_add(buf);
|
efreet_mime_monitor_add(buf);
|
||||||
}
|
}
|
||||||
efreet_mime_monitor_add("/etc/mime.types");
|
efreet_mime_monitor_add("/etc/mime.types");
|
||||||
|
|
|
@ -120,11 +120,11 @@ efreet_trash_delete_uri(Efreet_Uri *uri, int force_delete)
|
||||||
if (!uri || !uri->path || !ecore_file_can_write(uri->path)) return 0;
|
if (!uri || !uri->path || !ecore_file_can_write(uri->path)) return 0;
|
||||||
|
|
||||||
fname = ecore_file_file_get(uri->path);
|
fname = ecore_file_file_get(uri->path);
|
||||||
snprintf(dest, PATH_MAX, "%s/files/%s", efreet_trash_dir_get(), fname);
|
snprintf(dest, sizeof(dest), "%s/files/%s", efreet_trash_dir_get(), fname);
|
||||||
|
|
||||||
/* search for a free filename */
|
/* search for a free filename */
|
||||||
while (ecore_file_exists(dest))
|
while (ecore_file_exists(dest))
|
||||||
snprintf(dest, PATH_MAX, "%s/files/%s$%d",
|
snprintf(dest, sizeof(dest), "%s/files/%s$%d",
|
||||||
efreet_trash_dir_get(), fname, i++);
|
efreet_trash_dir_get(), fname, i++);
|
||||||
fname = ecore_file_file_get(dest);
|
fname = ecore_file_file_get(dest);
|
||||||
|
|
||||||
|
@ -148,7 +148,7 @@ efreet_trash_delete_uri(Efreet_Uri *uri, int force_delete)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* create info file */
|
/* create info file */
|
||||||
snprintf(dest, PATH_MAX, "%s/info/%s.trashinfo",
|
snprintf(dest, sizeof(dest), "%s/info/%s.trashinfo",
|
||||||
efreet_trash_dir_get(), fname);
|
efreet_trash_dir_get(), fname);
|
||||||
|
|
||||||
if ((f = fopen(dest, "w")))
|
if ((f = fopen(dest, "w")))
|
||||||
|
@ -184,7 +184,8 @@ EAPI int
|
||||||
efreet_trash_is_empty(void)
|
efreet_trash_is_empty(void)
|
||||||
{
|
{
|
||||||
char buf[PATH_MAX];
|
char buf[PATH_MAX];
|
||||||
snprintf(buf, PATH_MAX, "%s/files", efreet_trash_dir_get());
|
|
||||||
|
snprintf(buf, sizeof(buf), "%s/files", efreet_trash_dir_get());
|
||||||
|
|
||||||
/* TODO Check also trash in other filesystems */
|
/* TODO Check also trash in other filesystems */
|
||||||
return ecore_file_dir_is_empty(buf);
|
return ecore_file_dir_is_empty(buf);
|
||||||
|
@ -199,11 +200,11 @@ efreet_trash_empty_trash(void)
|
||||||
{
|
{
|
||||||
char buf[PATH_MAX];
|
char buf[PATH_MAX];
|
||||||
|
|
||||||
snprintf(buf, PATH_MAX, "%s/info", efreet_trash_dir_get());
|
snprintf(buf, sizeof(buf), "%s/info", efreet_trash_dir_get());
|
||||||
if (!ecore_file_recursive_rm(buf)) return 0;
|
if (!ecore_file_recursive_rm(buf)) return 0;
|
||||||
ecore_file_mkdir(buf);
|
ecore_file_mkdir(buf);
|
||||||
|
|
||||||
snprintf(buf, PATH_MAX, "%s/files", efreet_trash_dir_get());
|
snprintf(buf, sizeof(buf), "%s/files", efreet_trash_dir_get());
|
||||||
if (!ecore_file_recursive_rm(buf)) return 0;
|
if (!ecore_file_recursive_rm(buf)) return 0;
|
||||||
ecore_file_mkdir(buf);
|
ecore_file_mkdir(buf);
|
||||||
|
|
||||||
|
@ -226,7 +227,7 @@ efreet_trash_ls(void)
|
||||||
// NOTE THIS FUNCTION NOW IS NOT COMPLETE AS I DON'T NEED IT
|
// NOTE THIS FUNCTION NOW IS NOT COMPLETE AS I DON'T NEED IT
|
||||||
// TODO read the name from the infofile instead of the filename
|
// TODO read the name from the infofile instead of the filename
|
||||||
|
|
||||||
snprintf(buf, PATH_MAX, "%s/files", efreet_trash_dir_get());
|
snprintf(buf, sizeof(buf), "%s/files", efreet_trash_dir_get());
|
||||||
files = ecore_file_ls(buf);
|
files = ecore_file_ls(buf);
|
||||||
|
|
||||||
EINA_LIST_FOREACH(files, l, infofile)
|
EINA_LIST_FOREACH(files, l, infofile)
|
||||||
|
|
|
@ -623,9 +623,9 @@ efreet_util_cache_fill(__UNUSED__ void *data)
|
||||||
if (!file) break;
|
if (!file) break;
|
||||||
if (!strcmp(file->d_name, ".") || !strcmp(file->d_name, "..")) continue;
|
if (!strcmp(file->d_name, ".") || !strcmp(file->d_name, "..")) continue;
|
||||||
|
|
||||||
snprintf(buf, PATH_MAX, "%s/%s", fill->current->path, file->d_name);
|
snprintf(buf, sizeof(buf), "%s/%s", fill->current->path, file->d_name);
|
||||||
if (fill->current->file_id)
|
if (fill->current->file_id)
|
||||||
snprintf(file_id, PATH_MAX, "%s-%s", fill->current->file_id, file->d_name);
|
snprintf(file_id, sizeof(file_id), "%s-%s", fill->current->file_id, file->d_name);
|
||||||
else
|
else
|
||||||
strcpy(file_id, file->d_name);
|
strcpy(file_id, file->d_name);
|
||||||
|
|
||||||
|
@ -1160,7 +1160,7 @@ efreet_util_menus_find_helper(Eina_List *menus, const char *config_dir)
|
||||||
if (!exten) continue;
|
if (!exten) continue;
|
||||||
if (strcmp(".menu", exten)) continue;
|
if (strcmp(".menu", exten)) continue;
|
||||||
|
|
||||||
snprintf(fbuf, PATH_MAX, "%s/%s", dbuf, file->d_name);
|
snprintf(fbuf, sizeof(fbuf), "%s/%s", dbuf, file->d_name);
|
||||||
if (ecore_file_is_dir(fbuf)) continue;
|
if (ecore_file_is_dir(fbuf)) continue;
|
||||||
|
|
||||||
menus = eina_list_append(menus, strdup(fbuf));
|
menus = eina_list_append(menus, strdup(fbuf));
|
||||||
|
|
Loading…
Reference in New Issue