diff options
author | Samuel Thibault <samuel.thibault@ens-lyon.org> | 2015-05-23 00:33:04 +0530 |
---|---|---|
committer | Samuel Thibault <samuel.thibault@ens-lyon.org> | 2015-05-23 00:33:04 +0530 |
commit | bc0163aaa19ba102da3f73f30ca3f4cc11ba7a9d (patch) | |
tree | 40cbbd4e1cd6616222ef8aea15df2a0d758e35c4 | |
parent | 3ffb892a5db5ad64b87261fa01478401806894cf (diff) |
Make sure to record only RWX open modes
Thanks Svante Signell for the investigation and proposed patch.
* trans/fakeroot.c (new_node): Assert that `openmodes' includes only
O_RDWR|O_EXEC
(check_openmodes): Likewise with `newmodes'.
(netfs_S_dir_lookup): Keep only O_RDWR|O_EXEC from `flags' when calling
new_node.
-rw-r--r-- | trans/fakeroot.c | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/trans/fakeroot.c b/trans/fakeroot.c index 671314f4..99b6723a 100644 --- a/trans/fakeroot.c +++ b/trans/fakeroot.c @@ -75,6 +75,9 @@ new_node (file_t file, mach_port_t idport, int locked, int openmodes, { error_t err; struct netnode *nn; + + assert ((openmodes & ~(O_RDWR|O_EXEC)) == 0); + *np = netfs_make_node_alloc (sizeof *nn); if (*np == 0) { @@ -203,6 +206,8 @@ check_openmodes (struct netnode *nn, int newmodes, file_t file) { error_t err = 0; + assert ((newmodes & ~(O_RDWR|O_EXEC)) == 0); + if (newmodes &~ nn->openmodes) { /* The user wants openmodes we haven't tried before. */ @@ -390,7 +395,7 @@ netfs_S_dir_lookup (struct protid *diruser, else { pthread_spin_unlock (&netfs_node_refcnt_lock); - err = new_node (file, idport, 1, flags, &np); + err = new_node (file, idport, 1, flags & (O_RDWR|O_EXEC), &np); pthread_mutex_unlock (&dnp->lock); if (!err) { |