summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorJason Downs <downsj@cvs.openbsd.org>1999-08-03 09:18:31 +0000
committerJason Downs <downsj@cvs.openbsd.org>1999-08-03 09:18:31 +0000
commit770ef6ff81279f6a89955b304db960c0cd5aa562 (patch)
tree05637c7a5de88716ff232d7d57461271edc2f75c /lib
parentd7d53736a7483d044871dd76c61a673bf13779aa (diff)
Return an open failure if the fstab is zero length or not a regular file.
Diffstat (limited to 'lib')
-rw-r--r--lib/libc/gen/fstab.c15
1 files changed, 14 insertions, 1 deletions
diff --git a/lib/libc/gen/fstab.c b/lib/libc/gen/fstab.c
index 98cd34302ff..3c316644fa8 100644
--- a/lib/libc/gen/fstab.c
+++ b/lib/libc/gen/fstab.c
@@ -32,11 +32,12 @@
*/
#if defined(LIBC_SCCS) && !defined(lint)
-static char rcsid[] = "$OpenBSD: fstab.c,v 1.6 1997/07/09 00:28:19 millert Exp $";
+static char rcsid[] = "$OpenBSD: fstab.c,v 1.7 1999/08/03 09:18:30 downsj Exp $";
#endif /* LIBC_SCCS and not lint */
#include <sys/types.h>
#include <sys/uio.h>
+#include <sys/stat.h>
#include <errno.h>
#include <fstab.h>
#include <stdio.h>
@@ -174,12 +175,24 @@ getfsfile(name)
int
setfsent()
{
+ struct stat sbuf;
+
if (_fs_fp) {
rewind(_fs_fp);
return(1);
}
+
+ if (stat(_PATH_FSTAB, &sbuf) != 0)
+ goto fail;
+ if ((sbuf.st_size == 0) || ((sbuf.st_mode & S_IFMT) != S_IFREG)) {
+ errno = EFTYPE;
+ goto fail;
+ }
+
if ((_fs_fp = fopen(_PATH_FSTAB, "r")))
return(1);
+
+fail:
error(errno);
return(0);
}