summary refs log tree commit diff
path: root/dirent/scandir.c
diff options
context:
space:
mode:
authorRoland McGrath <roland@gnu.org>1996-01-31 10:00:24 +0000
committerRoland McGrath <roland@gnu.org>1996-01-31 10:00:24 +0000
commit01cdeca0c96838a92d9f810f9c4ae59e8129db2a (patch)
treec8f0ffd011deb496646771bf8fdf084e2c7281fb /dirent/scandir.c
parentf0b11018358086848fe3b141a9520e1c6128211b (diff)
downloadglibc-01cdeca0c96838a92d9f810f9c4ae59e8129db2a.tar.gz
glibc-01cdeca0c96838a92d9f810f9c4ae59e8129db2a.tar.xz
glibc-01cdeca0c96838a92d9f810f9c4ae59e8129db2a.zip
Tue Jan 30 13:32:05 1996 Roland McGrath <roland@churchy.gnu.ai.mit.edu> cvs/libc-960131
	* dirent/scandir.c: Allocate dirents with correct size for name, and
	copy with correct size.

	* hurd/hurdinit.c [! PIC] (map0): New function, on _hurd_preinit_hook.

	* stdio-common/vfscanf.c (TYPEMOD): New macro of all type modifier
	flag bits.
	(__vfscanf): Fix checking of extra type modifiers.

	* time/asia, time/australasia, time/backward: Updated from ADO 96b.

Tue Jan 30 12:17:26 1996  Ulrich Drepper  <drepper@ipd.info.uni-karlsruhe.de>

	* stdlib/strtod.c: Only negate exponent when there really is one.

	* stdio-common/vfscanf.c: Accept type modifiers on %n.
	Fix FP number parsing.
Diffstat (limited to 'dirent/scandir.c')
-rw-r--r--dirent/scandir.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/dirent/scandir.c b/dirent/scandir.c
index 65267affb7..e2ef63a9ce 100644
--- a/dirent/scandir.c
+++ b/dirent/scandir.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1992, 1993, 1994, 1995 Free Software Foundation, Inc.
+/* Copyright (C) 1992, 1993, 1994, 1995, 1996 Free Software Foundation, Inc.
 This file is part of the GNU C Library.
 
 The GNU C Library is free software; you can redistribute it and/or
@@ -19,6 +19,7 @@ Cambridge, MA 02139, USA.  */
 #include <ansidecl.h>
 #include <dirent.h>
 #include <stdlib.h>
+#include <string.h>
 #include <errno.h>
 
 int
@@ -44,6 +45,8 @@ DEFUN(scandir, (dir, namelist, select, cmp),
   while ((d = readdir (dp)) != NULL)
     if (select == NULL || (*select) (d))
       {
+	size_t dsize;
+
 	if (i == vsize)
 	  {
 	    struct dirent **new;
@@ -61,11 +64,12 @@ DEFUN(scandir, (dir, namelist, select, cmp),
 	    v = new;
 	  }
 
-	v[i] = (struct dirent *) malloc (sizeof (**v));
+	dsize = &d->d_name[d->d_namlen + 1] - (char *) d;
+	v[i] = (struct dirent *) malloc (dsize);
 	if (v[i] == NULL)
 	  goto lose;
 
-	*v[i++] = *d;
+	memcpy (v[i++], d, dsize);
       }
 
   if (errno != 0)