All of lore.kernel.org
 help / color / mirror / Atom feed
From: zkabelac@sourceware.org <zkabelac@sourceware.org>
To: lvm-devel@redhat.com
Subject: LVM2 ./WHATS_NEW lib/format_text/import_vsn1.c ...
Date: 13 Mar 2011 23:05:49 -0000	[thread overview]
Message-ID: <20110313230549.16622.qmail@sourceware.org> (raw)

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	zkabelac at sourceware.org	2011-03-13 23:05:49

Modified files:
	.              : WHATS_NEW 
	lib/format_text: import_vsn1.c 
	lib/format1    : import-export.c 
	lib/metadata   : metadata.c 

Log message:
	Fix allocation of system_id
	
	As code uses strncpy(system_id, NAME_LEN) and doesn't set '\0'
	Fix it by always allocating NAME_LEN + 1 buffer size and with zalloc
	we always get '\0' as the last byte.
	
	This bug may trigger some unexpected behavior of the string operation
	code - depends on the pool allocator.
	
	FIXME: refactor this code to alloc_vg.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.1953&r2=1.1954
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/format_text/import_vsn1.c.diff?cvsroot=lvm2&r1=1.84&r2=1.85
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/format1/import-export.c.diff?cvsroot=lvm2&r1=1.116&r2=1.117
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata.c.diff?cvsroot=lvm2&r1=1.448&r2=1.449

--- LVM2/WHATS_NEW	2011/03/13 22:57:51	1.1953
+++ LVM2/WHATS_NEW	2011/03/13 23:05:48	1.1954
@@ -1,5 +1,6 @@
 Version 2.02.85 - 
 ===================================
+  Fix allocation of system_id buffer in volume_group structure.
   Fix buffer allocation in build_dm_uuid().
   Fix readlink usage inside get_primary_dev().
   Use format instance mempool where possible and adequate.
--- LVM2/lib/format_text/import_vsn1.c	2011/03/11 14:50:15	1.84
+++ LVM2/lib/format_text/import_vsn1.c	2011/03/13 23:05:48	1.85
@@ -666,7 +666,7 @@
 	if (!(vg = alloc_vg("read_vg", fid->fmt->cmd, vgn->key)))
 		return_NULL;
 
-	if (!(vg->system_id = dm_pool_zalloc(vg->vgmem, NAME_LEN)))
+	if (!(vg->system_id = dm_pool_zalloc(vg->vgmem, NAME_LEN + 1)))
 		goto_bad;
 
 	vgn = vgn->child;
--- LVM2/lib/format1/import-export.c	2010/11/30 22:57:35	1.116
+++ LVM2/lib/format1/import-export.c	2011/03/13 23:05:48	1.117
@@ -225,7 +225,7 @@
 	if (!(vg->name = dm_pool_strdup(mem, (char *)dl->pvd.vg_name)))
 		return_0;
 
-	if (!(vg->system_id = dm_pool_alloc(mem, NAME_LEN)))
+	if (!(vg->system_id = dm_pool_zalloc(mem, NAME_LEN + 1)))
 		return_0;
 
 	*vg->system_id = '\0';
--- LVM2/lib/metadata/metadata.c	2011/03/11 15:10:17	1.448
+++ LVM2/lib/metadata/metadata.c	2011/03/13 23:05:49	1.449
@@ -934,7 +934,7 @@
 	}
 
 	vg->status = (RESIZEABLE_VG | LVM_READ | LVM_WRITE);
-	if (!(vg->system_id = dm_pool_alloc(vg->vgmem, NAME_LEN)))
+	if (!(vg->system_id = dm_pool_zalloc(vg->vgmem, NAME_LEN + 1)))
 		goto_bad;
 
 	*vg->system_id = '\0';



                 reply	other threads:[~2011-03-13 23:05 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20110313230549.16622.qmail@sourceware.org \
    --to=zkabelac@sourceware.org \
    --cc=lvm-devel@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.