The behavior of signed integer over/underflow is implementation-defined,
but even if the compiler is nice and just wraps around, we could get
ourselves into trouble later on.
Change-Id: I20ea9c790037a36b8527889b3f7adcfd60e74fd4
Reviewed-on: http://gerrit.openafs.org/10091
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Jeffrey Altman <jaltman@your-file-system.com>
Reviewed-by: Mark Vitale <mvitale@sinenomine.net>
Reviewed-by: Derrick Brashear <shadow@your-file-system.com>
if (flag & PRGRP) {
*aid = ntohl(cheader.maxGroup);
- while (code && i < maxcount) {
+ /* Check for PRBADID to avoid wrap-around. */
+ while (code && i < maxcount && *aid != PRBADID) {
--(*aid);
code = FindByID(at, *aid);
i++;
return PRSUCCESS;
} else {
*aid = ntohl(cheader.maxID);
- while (code && i < maxcount) {
+ while (code && i < maxcount && *aid != 0x7fffffff) {
++(*aid);
code = FindByID(at, *aid);
i++;