Hi

Dirlisting had a set of bugs. This set should fix them all.

The first one fixes filename corruption in large directories.

- Lauri
>From 4be1bb7b21431f3353e72f84cf0eeca8cddcbb27 Mon Sep 17 00:00:00 2001
From: Lauri Kasanen <[email protected]>
Date: Sun, 16 Dec 2012 14:07:16 +0200
Subject: [PATCH 1/7] dirlisting: Fix filename corruption

man readdir: "The  data returned by readdir() may be overwritten by subsequent 
calls to
readdir() for the same directory stream."

Before this, the plugin was saving a pointer to dirent->d_name, which got 
corrupted in any
big directory.

Signed-off-by: Lauri Kasanen <[email protected]>
---
 plugins/dirlisting/dirlisting.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/plugins/dirlisting/dirlisting.c b/plugins/dirlisting/dirlisting.c
index f8d1f4f..e4bc1df 100644
--- a/plugins/dirlisting/dirlisting.c
+++ b/plugins/dirlisting/dirlisting.c
@@ -116,7 +116,7 @@ static struct mk_f_list *mk_dirhtml_create_element(char 
*file,
         return NULL;
     }
 
-    entry->name = file;
+    entry->name = strdup(file);
     entry->type = type;
     entry->next = NULL;
 
@@ -641,6 +641,7 @@ static void mk_dirhtml_free_list(struct mk_f_list **toc, 
unsigned long len)
         if (entry->type != DT_DIR) {
             mk_api->mem_free(entry->size);
         }
+        mk_api->mem_free(entry->name);
         mk_api->mem_free(entry);
     }
 
-- 
1.7.2.1

_______________________________________________
Monkey mailing list
[email protected]
http://lists.monkey-project.com/listinfo/monkey

Reply via email to