From d43438bb914f267f1c65d81e23efbab6874ae426 Mon Sep 17 00:00:00 2001 From: Andrew Deason Date: Thu, 29 Sep 2011 18:36:07 -0500 Subject: [PATCH] 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 Reviewed-by: Derrick Brashear --- src/viced/fsstats.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/viced/fsstats.c b/src/viced/fsstats.c index ec933b9174..efaeb386f7 100644 --- a/src/viced/fsstats.c +++ b/src/viced/fsstats.c @@ -12,6 +12,7 @@ #include #include +#include #include #include @@ -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]); }