Re: Cyrus IMAPd 2.3.10 Released

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

>>>>> On Sat, 27 Oct 2007 14:02:59 +0200
>>>>> Tomas Janousek <tjanouse@xxxxxxxxxx> said:

tjanouse> On Fri, Oct 26, 2007 at 03:30:30PM -0400, Ken Murchison wrote:
>> Perhaps, it should be:
>>     do {
>> 	groupids = (gid_t *)xrealloc((gid_t *)groupids,
>> 				     ngroups * sizeof(gid_t));
>> 	newstate->ngroups = ngroups; /* copy of ngroups for comparision */
>> 	ret = getgrouplist(identifier, gid, groupids, &ngroups);
>> 	/*
>> 	 * This is tricky. We do this as long as getgrouplist tells us to
>> 	 * realloc _and_ the number of groups changes. It tells us to realloc
>> 	 * also in the case of failure...
>> 	 */
>>     } while (ret == -1 && ngroups == newstate->ngroups);
>>              ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>
> I think you're right on the 'ret == -1' test.  We want to stay in the loop 
> if getgrouplist() fails, AND it returns a different number of groups.  

tjanouse> Yes. It should read "ret == -1 && ngroups != newstate->ngroups". I'm really
tjanouse> confused why I put the "ret != -1" in there.

As far as I read the FreeBSD's getgrouplist() implementation, when it
returns -1, the number of the groups actually filled is set to
ngroups.  It is match with the following description in the manpage:

  RETURN VALUES
     The getgrouplist() function returns -1 if the size of the group list is
     too small to hold all the user's groups.  Here, the group array will be
     filled with as many groups as will fit.

So, I think that "ret == -1 && ngroups != newstate->ngroups" doesn't
work on at least FreeBSD.

Sincerely,

--
Hajimu UMEMOTO @ Internet Mutual Aid Society Yokohama, Japan
ume@xxxxxxxxxxxx  ume@{,jp.}FreeBSD.org
http://www.imasy.org/~ume/
----
Cyrus Home Page: http://cyrusimap.web.cmu.edu/
Cyrus Wiki/FAQ: http://cyrusimap.web.cmu.edu/twiki
List Archives/Info: http://asg.web.cmu.edu/cyrus/mailing-list.html

[Index of Archives]     [Cyrus SASL]     [Squirrel Mail]     [Asterisk PBX]     [Video For Linux]     [Photo]     [Yosemite News]     [gtk]     [KDE]     [Gimp on Windows]     [Steve's Art]

  Powered by Linux