From: mickey Date: Wed, 2 Apr 1997 05:20:02 +0000 (+0000) Subject: fd < 0 is evil X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=0014b71a79814214ddff4e1f192c5d65b7544d0a;p=openbsd fd < 0 is evil --- 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);