From a43ee99eec599dfcc4d0e473d1e518d3f96c6c19 Mon Sep 17 00:00:00 2001 From: Sebastien Buisson Date: Fri, 7 Sep 2012 13:52:56 +0200 Subject: [PATCH] LU-1856 build: fix 'out-of-bounds write' errors Fix 'out-of-bounds write' defects found by Coverity version 6.0.3: Out-of-bounds write (OVERRUN_DYNAMIC or OVERRUN_STATIC) Overrunning array at too high offset. Signed-off-by: Sebastien Buisson Change-Id: Idb2ed5f814bb0c4c9418cedffb8e01efae0f4bd7 Reviewed-on: http://review.whamcloud.com/3903 Tested-by: Hudson Tested-by: Maloo Reviewed-by: Andreas Dilger Reviewed-by: Keith Mannthey Reviewed-by: Oleg Drokin --- lustre/lov/lov_pack.c | 2 +- lustre/mdd/mdd_internal.h | 2 +- lustre/mdt/mdt_internal.h | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lustre/lov/lov_pack.c b/lustre/lov/lov_pack.c index a44a723..8553395 100644 --- a/lustre/lov/lov_pack.c +++ b/lustre/lov/lov_pack.c @@ -290,7 +290,7 @@ static int lov_verify_lmm(void *lmm, int lmm_bytes, __u16 *stripe_count) for (i = 0; i < lmm_bytes; i++) sprintf(buffer+2*i, "%.2X", ((char *)lmm)[i]); - buffer[sz] = '\0'; + buffer[sz - 1] = '\0'; CERROR("%s\n", buffer); OBD_FREE_LARGE(buffer, sz); } diff --git a/lustre/mdd/mdd_internal.h b/lustre/mdd/mdd_internal.h index b6c03aa..4396734 100644 --- a/lustre/mdd/mdd_internal.h +++ b/lustre/mdd/mdd_internal.h @@ -658,7 +658,7 @@ static inline void mdd_set_capainfo(const struct lu_env *env, int offset, struct md_capainfo *ci = md_capainfo(env); const struct lu_fid *fid = mdo2fid(obj); - LASSERT(offset >= 0 && offset <= MD_CAPAINFO_MAX); + LASSERT(offset >= 0 && offset < MD_CAPAINFO_MAX); /* NB: in mdt_init0 */ if (!ci) return; diff --git a/lustre/mdt/mdt_internal.h b/lustre/mdt/mdt_internal.h index 4c33a37..fbb10c0 100644 --- a/lustre/mdt/mdt_internal.h +++ b/lustre/mdt/mdt_internal.h @@ -821,7 +821,7 @@ static inline void mdt_set_capainfo(struct mdt_thread_info *info, int offset, { struct md_capainfo *ci; - LASSERT(offset >= 0 && offset <= MD_CAPAINFO_MAX); + LASSERT(offset >= 0 && offset < MD_CAPAINFO_MAX); if (!info->mti_mdt->mdt_opts.mo_mds_capa || !(info->mti_exp->exp_connect_flags & OBD_CONNECT_MDS_CAPA)) return; -- 1.8.3.1