From 56cd00a8f29eef06941758fb07a27a42cbbfaca5 Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Tue, 2 Apr 1996 14:18:49 +0000 Subject: (netfs_S_io_read): Verify that the user has the file open for reading. --- libnetfs/io-read.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/libnetfs/io-read.c b/libnetfs/io-read.c index 29b70a45..0cb257af 100644 --- a/libnetfs/io-read.c +++ b/libnetfs/io-read.c @@ -1,5 +1,5 @@ /* - Copyright (C) 1995 Free Software Foundation, Inc. + Copyright (C) 1995, 1996 Free Software Foundation, Inc. Written by Michael I. Bushnell, p/BSG. This file is part of the GNU Hurd. @@ -34,6 +34,14 @@ netfs_S_io_read (struct protid *user, if (!user) return EOPNOTSUPP; + mutex_lock (&user->po->np->lock); + + if ((user->po->openstat & O_READ) == 0) + { + mutex_unlock (&user->po->np->lock); + return EBADF; + } + if (amount > *datalen) { alloced = 1; @@ -41,7 +49,6 @@ netfs_S_io_read (struct protid *user, } *datalen = amount; - mutex_lock (&user->po->np->lock); err = netfs_attempt_read (user->credential, user->po->np, offset == -1 ? user->po->filepointer : offset, datalen, *data); -- cgit v1.2.3