From: Andrew Deason Date: Thu, 29 Sep 2011 23:36:07 +0000 (-0500) Subject: viced: Assert valid statistics indices X-Git-Tag: openafs-stable-1_8_0pre1~3207 X-Git-Url: https://git.openafs.org/?p=openafs.git;a=commitdiff_plain;h=d43438bb914f267f1c65d81e23efbab6874ae426 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 --- diff --git a/src/viced/fsstats.c b/src/viced/fsstats.c index ec933b9..efaeb38 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]); }