From: Mark Vitale Date: Thu, 23 May 2019 02:52:10 +0000 (-0400) Subject: pioctl: limit fruitless token searches X-Git-Tag: debian/1.8.4_pre1-1~9^2^2~13 X-Git-Url: https://git.michaelhowe.org/gitweb/?a=commitdiff_plain;h=27a21f35a81c3671c9752edfd4fa502f5fc281e0;p=packages%2Fo%2Fopenafs.git pioctl: limit fruitless token searches getNthCell searches the afs_users table for the nth token set belonging to a given user. However, it is impossible for a user to have more than one token set per cell. If the caller specifies a number greater than the total number of cells this cache manager knows about, we know the search will be fruitless. Instead, return early in this case, avoiding both the lock and the search. Reviewed-on: https://gerrit.openafs.org/13597 Tested-by: BuildBot Tested-by: Mark Vitale Reviewed-by: Michael Meffie Reviewed-by: Cheyenne Wills Reviewed-by: Benjamin Kaduk (cherry picked from commit fc7e1700fe84f623fb9163466d24226df00b1a2c) Change-Id: Idfda263af173a7ca081fcea3eef0ec4a63e66eda Reviewed-on: https://gerrit.openafs.org/13639 Tested-by: BuildBot Reviewed-by: Benjamin Kaduk Reviewed-by: Mark Vitale Reviewed-by: Cheyenne Wills Reviewed-by: Michael Meffie Reviewed-by: Stephan Wiesand --- diff --git a/src/afs/afs_pioctl.c b/src/afs/afs_pioctl.c index cfc79a2b7..8af2749ae 100644 --- a/src/afs/afs_pioctl.c +++ b/src/afs/afs_pioctl.c @@ -2274,6 +2274,9 @@ getNthCell(afs_int32 uid, afs_int32 iterator) { int i; struct unixuser *tu = NULL; + if (iterator > afs_cellindex) + return NULL; /* no point in looking */ + i = UHash(uid); ObtainReadLock(&afs_xuser); for (tu = afs_users[i]; tu; tu = tu->next) {