From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 7443 invoked by alias); 12 Apr 2011 14:13:19 -0000 Received: (qmail 7424 invoked by uid 9737); 12 Apr 2011 14:13:18 -0000 Date: Tue, 12 Apr 2011 14:13:00 -0000 Message-ID: <20110412141318.7422.qmail@sourceware.org> From: zkabelac@sourceware.org To: lvm-devel@redhat.com, lvm2-cvs@sourceware.org Subject: LVM2/lib/metadata mirror.c Mailing-List: contact lvm2-cvs-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Post: List-Help: , Sender: lvm2-cvs-owner@sourceware.org X-SW-Source: 2011-04/txt/msg00014.txt.bz2 CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: zkabelac@sourceware.org 2011-04-12 14:13:18 Modified files: lib/metadata : mirror.c Log message: Replace dm_snprintf with strncpy My previous patch fixed incorrect error check for dm_snprintf. However in this particular case - dm_snprintf has been used differently - just like strncpy + setting last char with '\0' - so the code had to return error - because the buffer was to short for whole string. Patch replaces it with real strncpy. Also test for alloca() failure is removed - as the program behaviour is rather undefined in this case - it never returns NULL. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/mirror.c.diff?cvsroot=lvm2&r1=1.149&r2=1.150 --- LVM2/lib/metadata/mirror.c 2011/04/09 19:05:24 1.149 +++ LVM2/lib/metadata/mirror.c 2011/04/12 14:13:17 1.150 @@ -1785,13 +1785,10 @@ lv_name = lv->name; suffix = "_mlogtmp_%d"; } else if ((lv_name = strstr(lv->name, MIRROR_SYNC_LAYER))) { - len = lv_name - lv->name + 1; - if (!(tmp_name = alloca(len)) || - (dm_snprintf(tmp_name, len, "%s", lv->name) < 0)) { - log_error("mirror log name allocation failed"); - return 0; - } - lv_name = tmp_name; + len = lv_name - lv->name; + tmp_name = alloca(len + 1); + tmp_name[len] = '\0'; + lv_name = strncpy(tmp_name, lv->name, len); suffix = "_mlog"; } else { lv_name = lv->name;