[uClibc-cvs] uClibc/libc/misc/glob glob.c,1.4,1.5

Erik Andersen andersen at uclibc.org
Tue Apr 29 07:26:04 UTC 2003


Update of /var/cvs/uClibc/libc/misc/glob
In directory winder:/tmp/cvs-serv2936

Modified Files:
	glob.c 
Log Message:
uClibc 0.9.19 has a bug in globfree(). If the previous call to
glob(...,pglob) used the GLOB_DOOFFS flag to reserve the first
pglob->gl_offs slots of pglob->gl_pathv, globfree(pglob) would attempt
to free the objects pointed to by those slots. If those objects were not
on the heap, the system would crash.

The attached patch fixes this.

Norm


Index: glob.c
===================================================================
RCS file: /var/cvs/uClibc/libc/misc/glob/glob.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- glob.c	3 Apr 2002 10:38:18 -0000	1.4
+++ glob.c	29 Apr 2003 07:25:59 -0000	1.5
@@ -260,8 +260,8 @@
 {
   if (pglob->gl_pathv != NULL)
     {
-      register int i;
-      for (i = 0; i < pglob->gl_pathc; ++i)
+      register int i = pglob->gl_flags & GLOB_DOOFFS? pglob->gl_offs : 0;
+      for (; i < pglob->gl_pathc; ++i)
 	if (pglob->gl_pathv[i] != NULL)
 	  free ((__ptr_t) pglob->gl_pathv[i]);
       free ((__ptr_t) pglob->gl_pathv);



More information about the uClibc-cvs mailing list