* lib/getugroups.c (getugroups): Include <limits.h>.
Instead, compare against INT_MAX, and increment only if the test passes.
+2008-02-13 Lasse Collin <lasse.collin@tukaani.org>
+
+ Don't rely on signed integer overflowing to negative value.
+ * lib/getugroups.c (getugroups): Include <limits.h>.
+ Instead, compare against INT_MAX, and increment only if the test passes.
+
2008-02-13 Jim Meyering <meyering@redhat.com>
and Eric Blake <ebb9@byu.net>
#include "getugroups.h"
+#include <limits.h>
#include <stdio.h> /* grp.h on alpha OSF1 V2.0 uses "FILE *". */
#include <grp.h>
goto done;
grouplist[count] = grp->gr_gid;
}
- count++;
- if (count < 0)
+ if (count == INT_MAX)
{
errno = EOVERFLOW;
goto done;
}
+ count++;
}
}
}