{
icon_t *info = (icon_t *)data;
const char *file = (const char *)node->children->content;
- char path[PATH_MAX];
+ char *path;
+ int size;
if (file[0] == '/') {
- snprintf(path, sizeof(path), "%s", file);
+ size = strlen(file) + 1;
+ path = (char *)malloc(size);
+ if (!path) {
+ LOGE("Out of memory");
+ return -1;
+ }
+
+ snprintf(path, size, "%s", file);
} else {
- snprintf(path, sizeof(path), "%s/shared/res/%s",
- __root_path, file);
- }
+ size = strlen(__root_path) + strlen("/shared/res/") +
+ strlen(file) + 1;
+ path = (char *)malloc(size);
+ if (!path) {
+ LOGE("Out of memory");
+ return -1;
+ }
- info->icon = strdup(path);
- if (!info->icon) {
- LOGE("Failed to duplicate icon");
- return -1;
+ snprintf(path, size, "%s/shared/res/%s", __root_path, file);
}
+ info->icon = path;
+
return 0;
}
static void path_callback(char *path)
{
- char orig_path[MAX_PATH] = {0, };
+ char orig_path[PATH_MAX] = {0, };
char *path_ptr = NULL;
int path_len = 0;
GList *tmp_list = g_list_find_custom(all_node_list, path, __compare_path);
else {
tmp_node_info = (resource_node_list_t *)tmp_list->data;
path_len = strlen(path);
- if (path_len >= MAX_PATH) {
+ if (path_len >= PATH_MAX) {
LOGE("path[%s] is too long", path);
return;
}
- strncpy(orig_path, path, path_len);
+ strncpy(orig_path, path, sizeof(orig_path) - path_len - 1);
path_ptr = &orig_path[strlen(res_path) + strlen(tmp_node_info->folder)];
g_hash_table_insert(id_list, strdup(path_ptr), strdup(tmp_node_info->type));
}
struct dirent **items;
int nitems, i;
struct stat fstat;
- char abs_path[MAX_PATH] = {0, };
+ char abs_path[PATH_MAX] = {0, };
char cwd[MAX_PATH] = {0, };
char *tmp = NULL;
if (items[i]->d_name[0] == '.')
continue;
- snprintf(abs_path, MAX_PATH - 1, "%s/%s", cwd, items[i]->d_name);
+ snprintf(abs_path, sizeof(abs_path), "%s/%s", cwd, items[i]->d_name);
if (g_lstat(abs_path, &fstat) != 0) {
LOGE("failed to retrieve info[%s]", abs_path);
static int __init_log(void)
{
int offset;
- char buffer[256] = {0, };
+ char buffer[512] = {0, };
char caller[255] = {0, };
int ret;
time_t now;
char time_buf[32] = {0,};
char format_buffer[WIDGET_LOG_BUFFER_STRING_SIZE];
- char buffer[WIDGET_LOG_BUFFER_STRING_SIZE];
+ char buffer[WIDGET_LOG_BUFFER_SIZE];
va_list ap;
if (!__log_init)