From fc7e1700fe84f623fb9163466d24226df00b1a2c Mon Sep 17 00:00:00 2001 From: Mark Vitale Date: Wed, 22 May 2019 22:52:10 -0400 Subject: [PATCH] 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. Change-Id: I509408d9aaa8f511813c4d82c121e199121bb8f3 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 --- src/afs/afs_pioctl.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/afs/afs_pioctl.c b/src/afs/afs_pioctl.c index 3152054..1d71bec 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) { -- 1.9.4