From: zkabelac@sourceware.org <zkabelac@sourceware.org>
To: lvm-devel@redhat.com
Subject: LVM2 ./WHATS_NEW lib/device/device.c
Date: 13 Mar 2011 22:52:21 -0000 [thread overview]
Message-ID: <20110313225221.11708.qmail@sourceware.org> (raw)
CVSROOT: /cvs/lvm2
Module name: LVM2
Changes by: zkabelac at sourceware.org 2011-03-13 22:52:20
Modified files:
. : WHATS_NEW
lib/device : device.c
Log message:
Fix usage of readlink
Return value of readlink limits valid string size.
Characters after returned size present some garbage to printf.
Fix it by placing '\0' on the return size value.
Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.1951&r2=1.1952
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/device/device.c.diff?cvsroot=lvm2&r1=1.36&r2=1.37
--- LVM2/WHATS_NEW 2011/03/11 15:10:16 1.1951
+++ LVM2/WHATS_NEW 2011/03/13 22:52:16 1.1952
@@ -1,5 +1,6 @@
Version 2.02.85 -
===================================
+ Fix readlink usage inside get_primary_dev().
Use format instance mempool where possible and adequate.
Call destroy_instance for any PVs found in VG structure during vg_free call.
Add new free_pv_fid fn and use it throughout to free all attached fids.
--- LVM2/lib/device/device.c 2010/12/15 12:49:55 1.36
+++ LVM2/lib/device/device.c 2011/03/13 22:52:20 1.37
@@ -287,7 +287,7 @@
struct stat info;
FILE *fp;
uint32_t pri_maj, pri_min;
- int ret = 0;
+ int size, ret = 0;
/* check if dev is a partition */
if (dm_snprintf(path, PATH_MAX, "%s/dev/block/%d:%d/partition",
@@ -309,11 +309,13 @@
* - basename ../../block/md0/md0 = md0
* Parent's 'dev' sysfs attribute = /sys/block/md0/dev
*/
- if (readlink(dirname(path), temp_path, PATH_MAX) < 0) {
+ if ((size = readlink(dirname(path), temp_path, PATH_MAX)) < 0) {
log_sys_error("readlink", path);
return ret;
}
+ temp_path[size] = '\0';
+
if (dm_snprintf(path, PATH_MAX, "%s/block/%s/dev",
sysfs_dir, basename(dirname(temp_path))) < 0) {
log_error("dm_snprintf dev failed");
next reply other threads:[~2011-03-13 22:52 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-03-13 22:52 zkabelac [this message]
-- strict thread matches above, loose matches on Subject: below --
2010-12-15 12:49 LVM2 ./WHATS_NEW lib/device/device.c agk
2009-07-09 22:50 snitzer
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=20110313225221.11708.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.