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];
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1666,7 +1666,7 @@ efreet_desktop_command_file_process(Efreet_Desktop_Command *command, const char
|
|||
{
|
||||
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);
|
||||
f->fullpath = strdup(buf);
|
||||
f->pending = 1;
|
||||
|
|
|
@ -847,7 +847,7 @@ efreet_icon_fallback_icon(const char *icon_name)
|
|||
|
||||
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);
|
||||
if (icon)
|
||||
{
|
||||
|
@ -858,7 +858,7 @@ efreet_icon_fallback_icon(const char *icon_name)
|
|||
|
||||
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);
|
||||
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,
|
||||
* 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");
|
||||
return 0;
|
||||
|
@ -1671,21 +1671,26 @@ efreet_menu_merge(Efreet_Menu_Internal *parent, Efreet_Xml *xml, const char *pat
|
|||
}
|
||||
|
||||
/* 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;
|
||||
}
|
||||
|
||||
eina_hash_add(efreet_merged_menus, realpath, (void *)1);
|
||||
|
||||
merge_xml = efreet_xml_new(realpath);
|
||||
FREE(realpath);
|
||||
|
||||
if (!merge_xml)
|
||||
{
|
||||
INF("efreet_menu_merge() failed to read in the "
|
||||
"merge file (%s)", realpath);
|
||||
FREE(realpath);
|
||||
return 0;
|
||||
}
|
||||
|
||||
FREE(realpath);
|
||||
|
||||
internal = efreet_menu_internal_new();
|
||||
efreet_menu_path_set(internal, path);
|
||||
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 (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))
|
||||
{
|
||||
closedir(files);
|
||||
|
@ -1980,7 +1985,7 @@ efreet_menu_handle_legacy_dir_helper(Efreet_Menu_Internal *root,
|
|||
|
||||
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));
|
||||
}
|
||||
else
|
||||
|
@ -3420,9 +3425,9 @@ efreet_menu_app_dir_scan(Efreet_Menu_Internal *internal, const char *path, const
|
|||
while ((file = readdir(files)))
|
||||
{
|
||||
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)
|
||||
snprintf(buf2, PATH_MAX, "%s-%s", id, file->d_name);
|
||||
snprintf(buf2, sizeof(buf2), "%s-%s", id, file->d_name);
|
||||
else
|
||||
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)))
|
||||
{
|
||||
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)
|
||||
snprintf(buf2, PATH_MAX, "%s/%s", relative_path, file->d_name);
|
||||
snprintf(buf2, sizeof(buf2), "%s/%s", relative_path, file->d_name);
|
||||
else
|
||||
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
|
||||
*/
|
||||
datadir = datahome;
|
||||
snprintf(buf, PATH_MAX, "%s/mime", datadir);
|
||||
snprintf(buf, sizeof(buf), "%s/mime", datadir);
|
||||
efreet_mime_monitor_add(buf);
|
||||
|
||||
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("/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;
|
||||
|
||||
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 */
|
||||
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++);
|
||||
fname = ecore_file_file_get(dest);
|
||||
|
||||
|
@ -148,7 +148,7 @@ efreet_trash_delete_uri(Efreet_Uri *uri, int force_delete)
|
|||
}
|
||||
|
||||
/* create info file */
|
||||
snprintf(dest, PATH_MAX, "%s/info/%s.trashinfo",
|
||||
snprintf(dest, sizeof(dest), "%s/info/%s.trashinfo",
|
||||
efreet_trash_dir_get(), fname);
|
||||
|
||||
if ((f = fopen(dest, "w")))
|
||||
|
@ -184,8 +184,9 @@ EAPI int
|
|||
efreet_trash_is_empty(void)
|
||||
{
|
||||
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 */
|
||||
return ecore_file_dir_is_empty(buf);
|
||||
}
|
||||
|
@ -199,11 +200,11 @@ efreet_trash_empty_trash(void)
|
|||
{
|
||||
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;
|
||||
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;
|
||||
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
|
||||
// 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);
|
||||
|
||||
EINA_LIST_FOREACH(files, l, infofile)
|
||||
|
|
|
@ -623,9 +623,9 @@ efreet_util_cache_fill(__UNUSED__ void *data)
|
|||
if (!file) break;
|
||||
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)
|
||||
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
|
||||
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 (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;
|
||||
|
||||
menus = eina_list_append(menus, strdup(fbuf));
|
||||
|
|
Loading…
Reference in New Issue