DCHECK_LE for cr_ngroups vs arraysize(cr_groups)

This DCHECK fails for me locally as

[----------] 3 tests from ProcessInfo
[ RUN      ] ProcessInfo.Self
[70989:10546846:20141216,112509.948519:FATAL process_info_mac.cc:114] Check failed: static_cast<size_t>(ngroups) < (sizeof(ArraySizeHelper(kern_proc_info_.kp_eproc.e_ucred.cr_groups))) (16 vs. 16).
Abort trap: 6

It doesn't seem to happen on the waterfall, so maybe I'm building against
an incorrect header? I don't particularly understand the code, but assuming
it's normal 0-based array, perhaps it should be a DCHECK_LE in any case.

R=mark@chromium.org

Review URL: https://codereview.chromium.org/813473002
This commit is contained in:
Scott Graham 2014-12-16 12:18:32 -08:00
parent 5adfa5039e
commit 4a5d21528e

View File

@ -110,7 +110,7 @@ std::set<gid_t> ProcessInfo::SupplementaryGroups() const {
const short ngroups = kern_proc_info_.kp_eproc.e_ucred.cr_ngroups; const short ngroups = kern_proc_info_.kp_eproc.e_ucred.cr_ngroups;
DCHECK_GE(ngroups, 0); DCHECK_GE(ngroups, 0);
DCHECK_LT(static_cast<size_t>(ngroups), DCHECK_LE(static_cast<size_t>(ngroups),
arraysize(kern_proc_info_.kp_eproc.e_ucred.cr_groups)); arraysize(kern_proc_info_.kp_eproc.e_ucred.cr_groups));
const gid_t* groups = kern_proc_info_.kp_eproc.e_ucred.cr_groups; const gid_t* groups = kern_proc_info_.kp_eproc.e_ucred.cr_groups;