Commit Graph

21 Commits

Author SHA1 Message Date
Jim Meyering
51fd72e0ea Include <stddef.h>.
(NULL): Don't define, since <stddef.h> does that.
2003-06-06 22:17:57 +00:00
Jim Meyering
2c63fed0e8 (savedir): Remove size parameter, as POSIX says that
a directory's st_size can have an arbitrary value, so the old
usage could waste an arbitrary amount of memory.  All uses
changed.
2001-08-31 09:09:53 +00:00
Jim Meyering
211b5731d7 savedir now sets errno on failure and invokes xmalloc to get memory.
Fix a couple of other minor bugs while we're at it.

(<unistd.h>): Do not include; there's no need.
(NAMLEN): Remove macro.
(malloc, realloc): Remove decls.
(stpcpy): Likewise.
("xalloc.h"): Include.
(NAME_SIZE_DEFAULT): New macro.
(savedir): Use xmalloc / xrealloc to allocate memory.
Use NAME_SIZE_DEFAULT if name_size is negative or overflows to zero.
Skip "" directory entries.
Use strlen to calculate directory entry length, since the old method
is rarely used these days and isn't worth supporting.
Don't use a pointer after freeing it.
Check for integer overflow when calculating allocation size.
Use memcpy to copy entries, instead of stpcpy.
Set errno properly when returning NULL.
Check for readdir error.
2000-06-27 07:08:48 +00:00
Jim Meyering
7157c29ee8 (savedir): Work even if directory size is
negative; this can happen with some screwy NFS configurations.
2000-03-08 14:50:05 +00:00
Jim Meyering
a2bee2bc6f (savedir): Don't store past the end of an array if
name_size is zero and the directory is empty.
2000-01-04 22:54:54 +00:00
Jim Meyering
89e470b8e2 fix typo 1999-08-08 10:16:53 +00:00
Jim Meyering
0bb442899e (savedir): Change type of name_size parameter to off_t. 1999-08-08 10:12:43 +00:00
Jim Meyering
7d60769bea ansideclify 1998-12-07 03:12:10 +00:00
Jim Meyering
bfbc3ce20c Use #if, not #ifdef with HAVE_ macros 1998-03-15 11:09:10 +00:00
Jim Meyering
9897ca0150 Declare stpcpy only if not defined as macro. 1997-12-25 16:49:08 +00:00
Jim Meyering
66fbc2c8f6 (savedir): Revert last change. malloc always
works when called with zero, because we use the wrapper if the
system version is lacking.
1997-11-30 14:20:17 +00:00
Jim Meyering
dcd4c05dfa (savedir): Check for size zero before invoking
malloc; this can occur if st_size arg overflows on conversion to
unsigned int.  All callers now cast st_size arg to unsigned int.
1997-11-30 10:24:41 +00:00
Jim Meyering
866a9c5e2d Use unsigned int, not just unsigned. 1997-10-24 13:17:16 +00:00
Jim Meyering
5873623fd5 (savedir): Declare DIR parameter to be const.
Include savedir.h.
1997-10-04 01:43:58 +00:00
Jim Meyering
e8b07e3796 update FSF address in copyright 1996-07-15 03:36:16 +00:00
Jim Meyering
154bd660bb merge with 3.9p 1994-10-20 16:16:39 +00:00
Jim Meyering
d8843f4b6e . 1994-10-17 14:01:44 +00:00
Jim Meyering
f1ce35a10c merge with 3.9h 1994-10-02 05:43:03 +00:00
Jim Meyering
f17c045d21 . 1994-10-02 02:09:38 +00:00
Jim Meyering
f1f85daaed . 1994-07-30 12:10:53 +00:00
Jim Meyering
14fd34b788 Initial revision 1992-10-31 20:42:48 +00:00