[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[E-devel] ecore_path_group_available patch



Hello,

I found L244 in e17/libs/ecore/src/lib/ecore/ecore_path.c
(ecore_path_group_available) a strdup with a non null-terminated string.
The cause is L239:  "strncpy(n, d->d_name, l - 2);"  (so
ecore_list_append(avail, strdup(n)); is wrong).

I propose a little patch (it sets '\0' and respects PATH_MAX).

Perhaps that the cvs version preserves the extension's dot (exemple "been.so"
-> "been." ), but I don't understand why so I didn't preserve this one in my
patch.

Aji.
Index: ecore_path.c
===================================================================
RCS file: /var/cvs/e/e17/libs/ecore/src/lib/ecore/ecore_path.c,v
retrieving revision 1.9
diff -u -r1.9 ecore_path.c
--- ecore_path.c	23 Jun 2006 06:40:52 -0000	1.9
+++ ecore_path.c	10 Dec 2006 17:56:50 -0000
@@ -234,9 +234,11 @@
 	     if (!S_ISREG(st.st_mode))
 	       continue;
 
-	     l = strlen(d->d_name);
-
-	     strncpy(n, d->d_name, l - 2);
+ 	     l = strlen(d->d_name);
+ 	     l = (l-2<PATH_MAX) ? l-2 : PATH_MAX;
+	     
+ 	     strncpy(n, d->d_name, l);
+ 	     n[l-1] = '\0';
 
 	     if (!avail)
 	       avail = ecore_list_new();