This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] aio_fsync: fix the access mode check


Hi,

the file access mode check in the pthread aio_fsync implementation 
wrongly uses the O_* constants, based on the way they are implemented on 
Linux (when O_RDONLY is 0). Attached there is a patch to properly use 
O_ACCMODE and O_RDONLY for the check.

I was able to successfully test it on Linux/x86_64 and Hurd/x86.

Thanks,
-- 
Pino Toscano
aio_fsync: fix the access mode check

Make use of O_ACCMODE and O_RDONLY instead of assuming details of the O_* flags.

2012-09-28  Pino Toscano  <toscano.pino@tiscali.it>

	* sysdeps/pthread/aio_fsync.c: Fix the file mode checking.
--- a/sysdeps/pthread/aio_fsync.c
+++ b/sysdeps/pthread/aio_fsync.c
@@ -46,7 +46,7 @@ aio_fsync (int op, struct aiocb *aiocbp)
 
   flags = fcntl (aiocbp->aio_fildes, F_GETFL);
   if (__builtin_expect (flags == -1, 0)
-      || __builtin_expect ((flags & (O_RDWR | O_WRONLY)) == 0, 0))
+      || __builtin_expect ((flags & O_ACCMODE) == O_RDONLY, 0))
     {
       __set_errno (EBADF);
       return -1;

Attachment: signature.asc
Description: This is a digitally signed message part.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]