savedir now sets errno on failure and invokes xmalloc to get memory.
authorJim Meyering <jim@meyering.net>
Tue, 27 Jun 2000 07:08:48 +0000 (07:08 +0000)
committerJim Meyering <jim@meyering.net>
Tue, 27 Jun 2000 07:08:48 +0000 (07:08 +0000)
commit49c86fdb3d58fc15ae14f804e0f69b681ff4fb70
tree79ed008385e763496e22b25bc2b221ca8e11b22b
parent661f3072043d3821a509eb6c5ca00cba76a69653
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.
lib/savedir.c