Skip to content

Commit 503e74e

Browse files
committed
Fix SECURITY_SQOS_PRESENT missing
if security_qos_flags(SECURITY_ANONYMOUS) is set
1 parent f47ec2a commit 503e74e

File tree

1 file changed

+5
-2
lines changed
  • src/libstd/sys/windows

1 file changed

+5
-2
lines changed

src/libstd/sys/windows/fs.rs

+5-2
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,11 @@ impl OpenOptions {
191191
pub fn access_mode(&mut self, access_mode: u32) { self.access_mode = Some(access_mode); }
192192
pub fn share_mode(&mut self, share_mode: u32) { self.share_mode = share_mode; }
193193
pub fn attributes(&mut self, attrs: u32) { self.attributes = attrs; }
194-
pub fn security_qos_flags(&mut self, flags: u32) { self.security_qos_flags = flags; }
194+
pub fn security_qos_flags(&mut self, flags: u32) {
195+
// We have to set `SECURITY_SQOS_PRESENT` here, because one of the valid flags we can
196+
// receive is `SECURITY_ANONYMOUS = 0x0`, which we can't check for later on.
197+
self.security_qos_flags = flags | c::SECURITY_SQOS_PRESENT;
198+
}
195199
pub fn security_attributes(&mut self, attrs: c::LPSECURITY_ATTRIBUTES) {
196200
self.security_attributes = attrs as usize;
197201
}
@@ -239,7 +243,6 @@ impl OpenOptions {
239243
self.custom_flags |
240244
self.attributes |
241245
self.security_qos_flags |
242-
if self.security_qos_flags != 0 { c::SECURITY_SQOS_PRESENT } else { 0 } |
243246
if self.create_new { c::FILE_FLAG_OPEN_REPARSE_POINT } else { 0 }
244247
}
245248
}

0 commit comments

Comments
 (0)