};
struct entry_node *push_entry(char *name, struct entry_node *head) {
+ char tmp_name[PATH_MAX];
struct entry_node *result;
int isdir;
result = safe_malloc(sizeof(struct entry_node));
result->size = entry_size(name, &isdir);
if(isdir) {
- result->name = safe_malloc(sizeof(char) * strlen(name) + 2);
- sprintf(result->name, "%s/", name);
+ snprintf(tmp_name, PATH_MAX, "%s/", name);
+ result->name = strdup(tmp_name);
} else {
result->name = strdup(name);
}