Whamcloud - gitweb
LU-6395 mgc: one byte shorter for logname allocation 46/14146/2
authorwang di <di.wang@intel.com>
Sun, 22 Mar 2015 15:15:19 +0000 (08:15 -0700)
committerOleg Drokin <oleg.drokin@intel.com>
Wed, 25 Mar 2015 23:58:23 +0000 (23:58 +0000)
One byte shorter for logname allocation in mgc_llog_local_copy(),
which might cause buffer overflow in the following sprintf().

Signed-off-by: wang di <di.wang@intel.com>
Change-Id: Ie758c3650c1cf7848874d9fd3a02a5618043eb8f
Reviewed-on: http://review.whamcloud.com/14146
Tested-by: Jenkins
Reviewed-by: Andreas Dilger <andreas.dilger@intel.com>
Reviewed-by: Mike Pershin <mike.pershin@intel.com>
Tested-by: Maloo <hpdd-maloo@intel.com>
lustre/mgc/mgc_request.c

index c14e760..72827eb 100644 (file)
@@ -1717,7 +1717,7 @@ static int mgc_llog_local_copy(const struct lu_env *env,
         * - if failed then move bakup to logname again
         */
 
-       OBD_ALLOC(temp_log, strlen(logname) + 1);
+       OBD_ALLOC(temp_log, strlen(logname) + 2);
        if (!temp_log)
                RETURN(-ENOMEM);
        sprintf(temp_log, "%sT", logname);
@@ -1739,7 +1739,7 @@ out:
                       obd->obd_name, logname, rc);
        }
        llog_erase(env, lctxt, NULL, temp_log);
-       OBD_FREE(temp_log, strlen(logname) + 1);
+       OBD_FREE(temp_log, strlen(logname) + 2);
        return rc;
 }