On Monday 13 June 2011 14:11, Alexey Fomenko wrote:
> Hello!
> 
> In coreutils/id.c get_groups() gets groups list for further printing out
> on screen. According to id's main function - return value from
> get_groups is expected even < 0 in order to extend (xrealloc) the
> list size for the groups in case if there's more than 64:
> >     123 int id_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
> >     124 int id_main(int argc UNUSED_PARAM, char **argv)
> >     125 {
> ...  
> >     180                 n = 64;
> >     181                 if (get_groups(username, rgid, groups, &n) < 0) {
> >     182                         /* Need bigger buffer after all */
> >     183                         groups = xrealloc(groups, n * 
> > sizeof(gid_t));
> >     184                         get_groups(username, rgid, groups, &n);
> >     185                 }
> >     186                 if (n > 0) {
> But get_groups() allowed to return only >=0 value:
> >     96 static int get_groups(const char *username, gid_t rgid, gid_t 
> > *groups, int *n)
> ...
> >     118         if (*n < 0)
> >     119                 return 0; /* error, don't return < 0! */
> >     120         return m;
> >     121 }

Why do you think so? It says "if (*n < 0)", not "if (m < 0)".

-- 
vda
_______________________________________________
busybox mailing list
[email protected]
http://lists.busybox.net/mailman/listinfo/busybox

Reply via email to