From d22be169326f39961cd96bb3e4cb8ed6c2e2fbb8 Mon Sep 17 00:00:00 2001 From: Michael Gehring Date: Mon, 16 Jun 2014 21:05:39 +0200 Subject: [PATCH] c_types: handle errors from getgroups()/getgrouplist() --- common/c_types.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/common/c_types.rs b/common/c_types.rs index 77d5fbf92..adbd06b10 100644 --- a/common/c_types.rs +++ b/common/c_types.rs @@ -13,6 +13,7 @@ use self::libc::funcs::posix88::unistd::getgroups; use std::vec::Vec; +use std::io::IoError; use std::ptr::read; use std::str::raw::from_c_str; @@ -138,6 +139,9 @@ pub fn group(possible_pw: Option, nflag: bool) { }; } + if ngroups < 0 { + crash!(1, "{}", IoError::last_error()); + } unsafe { groups.set_len(ngroups as uint) };