Whamcloud - gitweb
LU-1856 build: fix 'out-of-bounds write' errors
authorSebastien Buisson <sebastien.buisson@bull.net>
Fri, 7 Sep 2012 11:52:56 +0000 (13:52 +0200)
committerOleg Drokin <green@whamcloud.com>
Mon, 17 Sep 2012 21:45:57 +0000 (17:45 -0400)
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 <sebastien.buisson@bull.net>
Change-Id: Idb2ed5f814bb0c4c9418cedffb8e01efae0f4bd7
Reviewed-on: http://review.whamcloud.com/3903
Tested-by: Hudson
Tested-by: Maloo <whamcloud.maloo@gmail.com>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Reviewed-by: Keith Mannthey <keith@whamcloud.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
lustre/lov/lov_pack.c
lustre/mdd/mdd_internal.h
lustre/mdt/mdt_internal.h

index a44a723..8553395 100644 (file)
@@ -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);
                 }
index b6c03aa..4396734 100644 (file)
@@ -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;
index 4c33a37..fbb10c0 100644 (file)
@@ -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;