Skip to content

Commit ac60d0e

Browse files
kbouchard-devawakecoding
authored andcommitted
feat(pedm): fix dead pointer in ACL wrapper
1 parent 6b77a99 commit ac60d0e

File tree

1 file changed

+8
-16
lines changed
  • crates/win-api-wrappers/src/security

1 file changed

+8
-16
lines changed

crates/win-api-wrappers/src/security/acl.rs

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -327,20 +327,12 @@ impl TryFrom<&SecurityDescriptor> for RawSecurityDescriptor {
327327
fn try_from(value: &SecurityDescriptor) -> std::result::Result<Self, Self::Error> {
328328
let owner = value.owner.as_ref().map(RawSid::try_from).transpose()?;
329329
let group = value.group.as_ref().map(RawSid::try_from).transpose()?;
330-
let sacl = value
331-
.sacl
332-
.as_ref()
333-
.map(|x| x.acl.to_raw().map(|y| (x.kind, y)))
334-
.transpose()?;
330+
let sacl = value.sacl.as_ref().map(|x| x.acl.to_raw()).transpose()?;
335331

336-
let dacl = value
337-
.dacl
338-
.as_ref()
339-
.map(|x| x.acl.to_raw().map(|y| (x.kind, y)))
340-
.transpose()?;
332+
let dacl = value.dacl.as_ref().map(|x| x.acl.to_raw()).transpose()?;
341333

342334
let mut control = SECURITY_DESCRIPTOR_CONTROL(0);
343-
if let Some((kind, _)) = sacl {
335+
if let Some(kind) = value.sacl.as_ref().map(|x| x.kind) {
344336
control |= SE_SACL_PRESENT;
345337

346338
control |= match kind {
@@ -350,7 +342,7 @@ impl TryFrom<&SecurityDescriptor> for RawSecurityDescriptor {
350342
};
351343
}
352344

353-
if let Some((kind, _)) = dacl {
345+
if let Some(kind) = value.dacl.as_ref().map(|x| x.kind) {
354346
control |= SE_DACL_PRESENT;
355347

356348
control |= match kind {
@@ -371,17 +363,17 @@ impl TryFrom<&SecurityDescriptor> for RawSecurityDescriptor {
371363
Group: group.as_ref().map(RawSid::as_psid).unwrap_or_default(),
372364
Sacl: sacl
373365
.as_ref()
374-
.map_or_else(ptr::null_mut, |x| x.1.as_ptr().cast_mut().cast()),
366+
.map_or_else(ptr::null_mut, |x| x.as_ptr().cast_mut().cast()),
375367
Dacl: dacl
376368
.as_ref()
377-
.map_or_else(ptr::null_mut, |x| x.1.as_ptr().cast_mut().cast()),
369+
.map_or_else(ptr::null_mut, |x| x.as_ptr().cast_mut().cast()),
378370
};
379371

380372
Ok(Self {
381373
_owner: owner,
382374
_group: group,
383-
_sacl: sacl.map(|x| x.1),
384-
_dacl: dacl.map(|x| x.1),
375+
_sacl: sacl,
376+
_dacl: dacl,
385377
raw,
386378
})
387379
}

0 commit comments

Comments
 (0)