viced: Assert valid statistics indices

Make sure we are passed valid statistic index numbers, so passing in a
bad index doesn't result in writing over random memory.

Change-Id: I29ed03b59df937e6f95fba44209a03db23613a8d
Reviewed-on: http://gerrit.openafs.org/5525
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Derrick Brashear <shadow@dementix.org>
This commit is contained in:
Andrew Deason 2011-09-29 18:36:07 -05:00 committed by Derrick Brashear
parent 22d94407ea
commit d43438bb91

View File

@ -12,6 +12,7 @@
#include <afsconfig.h>
#include <afs/param.h>
#include <assert.h>
#include <roken.h>
#include <afs/afsint.h>
@ -25,6 +26,7 @@
void
fsstats_StartOp(struct fsstats *stats, int index)
{
assert(index >= 0 && index < FS_STATS_NUM_RPC_OPS);
stats->opP = &(afs_FullPerfStats.det.rpcOpTimes[index]);
FS_LOCK;
(stats->opP->numOps)++;
@ -57,6 +59,7 @@ fsstats_FinishOp(struct fsstats *stats, int code)
void
fsstats_StartXfer(struct fsstats *stats, int index)
{
assert(index >= 0 && index < FS_STATS_NUM_XFER_OPS);
FT_GetTimeOfDay(&stats->xferStartTime, NULL);
stats->xferP = &(afs_FullPerfStats.det.xferOpTimes[index]);
}