diff options
author | Michael Shalayeff <mickey@cvs.openbsd.org> | 1997-04-02 05:20:03 +0000 |
---|---|---|
committer | Michael Shalayeff <mickey@cvs.openbsd.org> | 1997-04-02 05:20:03 +0000 |
commit | 471eac0e1b823971765a6f790c8ff05fa647c495 (patch) | |
tree | f95f1f170ce6d5f4513ee20857c5e7c52d55d3f6 /sys/lib/libsa | |
parent | cff85ee6e151ec56a32b923ed785d2276a6075be (diff) |
fd < 0 is evil
Diffstat (limited to 'sys/lib/libsa')
-rw-r--r-- | sys/lib/libsa/readdir.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/sys/lib/libsa/readdir.c b/sys/lib/libsa/readdir.c index 5671962ecab..b01ecdda9b0 100644 --- a/sys/lib/libsa/readdir.c +++ b/sys/lib/libsa/readdir.c @@ -1,4 +1,4 @@ -/* $OpenBSD: readdir.c,v 1.1 1997/02/16 14:48:06 mickey Exp $ */ +/* $OpenBSD: readdir.c,v 1.2 1997/04/02 05:20:02 mickey Exp $ */ /* * Copyright (c) 1996 Michael Shalayeff @@ -69,10 +69,12 @@ readdir(fd, dest) { register struct open_file *f = &files[fd]; - if ((unsigned)fd >= SOPEN_MAX || !(f->f_flags & F_READ)) { + if (fd < 0 || fd >= SOPEN_MAX || + !((f = &files[fd])->f_flags & F_READ)) { errno = EBADF; return (-1); } + if (f->f_flags & F_RAW) { errno = EINVAL; return (-1); |