From 4f9624bf078064cfcd49da714437e0ed94bbffbe Mon Sep 17 00:00:00 2001 From: Richard Wareing Date: Fri, 17 Oct 2014 18:35:56 -0700 Subject: Fixes gNFSd gf_update_latency crashes Summary: - Per title, does a bounds check on the frame->op and bails from the function if it's invalid preventing the crash Test Plan: Prove tests Reviewers: dph, jackl Reviewed By: jackl FB-commit-id: e67cc15 Change-Id: If1a5a9c0630573d4a6615050a9114ccf532551c7 Signed-off-by: Kevin Vigor Reviewed-on: https://review.gluster.org/16847 CentOS-regression: Gluster Build System NetBSD-regression: NetBSD Build System Smoke: Gluster Build System Reviewed-by: Shreyas Siravara --- libglusterfs/src/latency.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/libglusterfs/src/latency.c b/libglusterfs/src/latency.c index 3399cc7c297..d51e64768aa 100644 --- a/libglusterfs/src/latency.c +++ b/libglusterfs/src/latency.c @@ -137,6 +137,13 @@ gf_update_latency (call_frame_t *frame) elapsed = (end->tv_sec - begin->tv_sec) * 1e6 + (end->tv_usec - begin->tv_usec); + if (frame->op < 0 || frame->op >= GF_FOP_MAXVALUE) { + gf_log ("[core]", GF_LOG_WARNING, + "Invalid frame op value: %d", + frame->op); + return; + } + lat = &frame->this->latencies[frame->op]; lat->total += elapsed; -- cgit