Skip to content

Commit e8958c6

Browse files
vvb2060topjohnwu
authored andcommitted
get_secontext: ignore ENODATA
1 parent e8a3bf8 commit e8958c6

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

native/src/base/files.rs

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -733,10 +733,12 @@ impl FsPath {
733733
XATTR_NAME_SELINUX.as_ptr().cast(),
734734
con.as_mut_ptr().cast(),
735735
con.capacity(),
736-
)
737-
.check_os_err()?;
736+
);
738737
if sz < 1 {
739738
con.clear();
739+
if *errno() != libc::ENODATA {
740+
return Err(io::Error::last_os_error());
741+
}
740742
} else {
741743
con.set_len((sz - 1) as usize);
742744
}
@@ -840,9 +842,14 @@ pub fn fd_get_attr(fd: RawFd) -> io::Result<FileAttr> {
840842
XATTR_NAME_SELINUX.as_ptr().cast(),
841843
attr.con.as_mut_ptr().cast(),
842844
attr.con.capacity(),
843-
)
844-
.check_os_err()?;
845-
attr.con.set_len((sz - 1) as usize);
845+
);
846+
if sz < 1 {
847+
if *errno() != libc::ENODATA {
848+
return Err(io::Error::last_os_error());
849+
}
850+
} else {
851+
attr.con.set_len((sz - 1) as usize);
852+
}
846853
}
847854
}
848855
Ok(attr)

0 commit comments

Comments
 (0)