summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/unistd.rs20
1 files changed, 16 insertions, 4 deletions
diff --git a/src/unistd.rs b/src/unistd.rs
index 89edcbef..fc3c405d 100644
--- a/src/unistd.rs
+++ b/src/unistd.rs
@@ -3750,11 +3750,23 @@ impl From<&libc::group> for Group {
fn from(gr: &libc::group) -> Group {
unsafe {
Group {
- name: CStr::from_ptr(gr.gr_name).to_string_lossy().into_owned(),
- passwd: CString::new(CStr::from_ptr(gr.gr_passwd).to_bytes())
- .unwrap(),
+ name: if gr.gr_name.is_null() {
+ Default::default()
+ } else {
+ CStr::from_ptr(gr.gr_name).to_string_lossy().into_owned()
+ },
+ passwd: if gr.gr_passwd.is_null() {
+ Default::default()
+ } else {
+ CString::new(CStr::from_ptr(gr.gr_passwd).to_bytes())
+ .unwrap()
+ },
gid: Gid::from_raw(gr.gr_gid),
- mem: Group::members(gr.gr_mem),
+ mem: if gr.gr_mem.is_null() {
+ Default::default()
+ } else {
+ Group::members(gr.gr_mem)
+ },
}
}
}