Whamcloud - gitweb
LU-2227 build: fix 'memory illegal access' errors
[fs/lustre-release.git] / lustre / lov / lov_ea.c
index 34ab86d..51a9118 100644 (file)
@@ -293,11 +293,15 @@ int lsm_unpackmd_v3(struct lov_obd *lov, struct lov_stripe_md *lsm,
         struct lov_oinfo *loi;
         int i;
         __u64 stripe_maxbytes = OBD_OBJECT_EOF;
         struct lov_oinfo *loi;
         int i;
         __u64 stripe_maxbytes = OBD_OBJECT_EOF;
+       int cplen = 0;
 
         lmm = (struct lov_mds_md_v3 *)lmmv1;
 
         lsm_unpackmd_common(lsm, (struct lov_mds_md_v1 *)lmm);
 
         lmm = (struct lov_mds_md_v3 *)lmmv1;
 
         lsm_unpackmd_common(lsm, (struct lov_mds_md_v1 *)lmm);
-        strncpy(lsm->lsm_pool_name, lmm->lmm_pool_name, LOV_MAXPOOLNAME);
+       cplen = strlcpy(lsm->lsm_pool_name, lmm->lmm_pool_name,
+                       sizeof(lsm->lsm_pool_name));
+       if (cplen >= sizeof(lsm->lsm_pool_name))
+               return -E2BIG;
 
         for (i = 0; i < lsm->lsm_stripe_count; i++) {
                 /* XXX LOV STACKING call down to osc_unpackmd() */
 
         for (i = 0; i < lsm->lsm_stripe_count; i++) {
                 /* XXX LOV STACKING call down to osc_unpackmd() */