master - raid_manip: allow for raid leg to be replaced when not both data and metadata image are on pvs
by Heinz Mauelshagen
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=18cf5e8e6758db...
Commit: 18cf5e8e6758db59c9413bd9c9abcc183c49293d
Parent: d03b1779b4e2edaec221e2c29d3384d4c86052cd
Author: Heinz Mauelshagen <heinzm(a)redhat.com>
AuthorDate: Mon Mar 7 15:25:30 2016 +0100
Committer: Heinz Mauelshagen <heinzm(a)redhat.com>
CommitterDate: Mon Mar 7 15:25:30 2016 +0100
raid_manip: allow for raid leg to be replaced when not both data and metadata image are on pvs
resolves rhbz#1130329
---
lib/metadata/raid_manip.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/lib/metadata/raid_manip.c b/lib/metadata/raid_manip.c
index 3b9f81c..887b27f 100644
--- a/lib/metadata/raid_manip.c
+++ b/lib/metadata/raid_manip.c
@@ -914,7 +914,7 @@ static int _raid_extract_images(struct logical_volume *lv, uint32_t new_count,
display_lvname(seg_lv(seg, s)));
} else {
/* Conditions for second pass */
- if (!lv_is_on_pvs(seg_lv(seg, s), target_pvs) ||
+ if (!lv_is_on_pvs(seg_lv(seg, s), target_pvs) &&
!lv_is_on_pvs(seg_metalv(seg, s), target_pvs))
continue;
8 years, 1 month
master - coverity: fix possible resource leak in _print_historical_lv function
by Peter Rajnoha
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=d03b1779b4e2ed...
Commit: d03b1779b4e2edaec221e2c29d3384d4c86052cd
Parent: 7b15ca5c9ac3645b8d714014f89dbcd6731b2b04
Author: Peter Rajnoha <prajnoha(a)redhat.com>
AuthorDate: Mon Mar 7 10:32:41 2016 +0100
Committer: Peter Rajnoha <prajnoha(a)redhat.com>
CommitterDate: Mon Mar 7 10:43:50 2016 +0100
coverity: fix possible resource leak in _print_historical_lv function
The code in _print_historical_lv function works with temporary
"descendants_buffer" that is allocated and freed within this
function.
When printing text out, we used "outf" macro which called
"out_text" fn and it checked return value and if failed,
the macro called "return_0" automatically. But since we
use the temporary buffer, if any of the out_text calls
fails, we need to deallocate this buffer properly - that's
the "goto_out", otherwise we'll be leaking memory.
So add new "outfgo" helper macro which does the same as "outf",
but it calls "goto_out" instead of "return_0" so we can jump
to a cleanup hook at the end.
---
lib/format_text/export.c | 12 ++++++------
lib/format_text/text_export.h | 1 +
2 files changed, 7 insertions(+), 6 deletions(-)
diff --git a/lib/format_text/export.c b/lib/format_text/export.c
index c4c7b38..90fb044 100644
--- a/lib/format_text/export.c
+++ b/lib/format_text/export.c
@@ -854,10 +854,10 @@ static int _print_historical_lv(struct formatter *f, struct historical_logical_v
goto_out;
outnl(f);
- outf(f, "%s {", hlv->name);
+ outfgo(f, "%s {", hlv->name);
_inc_indent(f);
- outf(f, "id = \"%s\"", buffer);
+ outfgo(f, "id = \"%s\"", buffer);
if (!_print_timestamp(f, "creation_time", hlv->timestamp, buffer, sizeof(buffer)))
goto_out;
@@ -867,16 +867,16 @@ static int _print_historical_lv(struct formatter *f, struct historical_logical_v
if (hlv->indirect_origin) {
if (hlv->indirect_origin->is_historical)
- outf(f, "origin = \"%s%s\"", HISTORICAL_LV_PREFIX, hlv->indirect_origin->historical->name);
+ outfgo(f, "origin = \"%s%s\"", HISTORICAL_LV_PREFIX, hlv->indirect_origin->historical->name);
else
- outf(f, "origin = \"%s\"", hlv->indirect_origin->live->name);
+ outfgo(f, "origin = \"%s\"", hlv->indirect_origin->live->name);
}
if (descendants_buffer)
- outf(f, "descendants = %s", descendants_buffer);
+ outfgo(f, "descendants = %s", descendants_buffer);
_dec_indent(f);
- outf(f, "}");
+ outfgo(f, "}");
r = 1;
out:
diff --git a/lib/format_text/text_export.h b/lib/format_text/text_export.h
index 33c136b..377ee93 100644
--- a/lib/format_text/text_export.h
+++ b/lib/format_text/text_export.h
@@ -20,6 +20,7 @@
#define outhint(args...) do {if (!out_hint(args)) return_0;} while (0)
#define outfc(args...) do {if (!out_text_with_comment(args)) return_0;} while (0)
#define outf(args...) do {if (!out_text(args)) return_0;} while (0)
+#define outfgo(args...) do {if (!out_text(args)) goto_out;} while (0)
#define outnl(f) do {if (!out_newline(f)) return_0;} while (0)
struct formatter;
8 years, 1 month
v2_02_145 annotated tag has been created
by Alasdair Kergon
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=7a03ddc3744a8c...
Commit: 7a03ddc3744a8cef3728a7feb7d7302f3d7b1e48
Parent: 0000000000000000000000000000000000000000
Author: Alasdair G Kergon <agk(a)redhat.com>
AuthorDate: 2016-03-04 18:02 +0000
Committer: Alasdair G Kergon <agk(a)redhat.com>
CommitterDate: 2016-03-04 18:02 +0000
annotated tag: v2_02_145 has been created
at 7a03ddc3744a8cef3728a7feb7d7302f3d7b1e48 (tag)
tagging 68ec240b99fca4e0860cb6e1b17ce4b888eb2585 (commit)
replaces v2_02_144
Release 2.02.145.
Another development release - recent interface changes are still not frozen.
83 files changed, 2694 insertions(+), 607 deletions(-)
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.14 (GNU/Linux)
iEYEABECAAYFAlbZzeQACgkQIoGRwVZ+LBcrYQCfVvBtj1E6fhR6wbk91SYH83OI
NpUAoLAOGoHKFuWJqN5CB0RXzxM8WfcC
=TpKw
-----END PGP SIGNATURE-----
Alasdair G Kergon (3):
post-release
man: Add some information about historical LVs.
pre-release
David Teigland (6):
pvs: display VG name [unknown] for used PV without metadata
tests: check [unknown] in lvmetad-pvscan-cache
update WHATS_NEW
pvs: replace 'unknown device' with [unknown]
WHATS_NEW: [unknown] replaces 'unknown device'
tests: direct control of lvm1 usage in tests
Marian Csontos (1):
dbustest.sh: Get dbus test to work on buildbot
Peter Rajnoha (44):
metadata: add infrastructure to track LV history
metadata: add get_or_create_glv and get_or_create_glvl
metadata: add add_glv_to_indirect_glvs and remove_glv_from_indirect_glvs
metadata: create historical LVs when LVs are removed and interconnect with live LVs
metadata: format_text: also export historical LVs
metadata: format_text: reuse _print_timestamp fn
metadata: format_text: import historical LVs
metadata: add find_historical_glv fn
metadata: add support for interconnection of thin pool LV segment with indirect origin
metadata: format_text: interconnect historical LVs among each other and also with live LVs
metadata: add lv_is_historical fn to test if the LV is historical one
cmd: add '-H|--history' switch and wire it up in cmd_context and processing_handle
toollib: honour '-H|--history' switch while executing process_each_lv_in_vg
report: display lv_name,lv_uuid,vg_name,lv_time and new lv_time_removed for historical LVs
commands: lvs: recognize -H|--history switch
report: add lv_historical field to identify historical LVs
report: display (h)istorical state in lv_attr field
report: report historical LV names with '-' prefix
report: add full_ancestors field to display ancestors with history
report: add full_descendants field to display descendants with history
report: add new 'none' lv_layout and 'history' lv_role and mark historical LVs that way
cmd: add 'nohistory' option and wire it up in cmd_context
metadata: honour 'nohistory' switch when removing thin LVs
commands: lvremove: recognize --nohistory option
conf: add metadata/record_lvs_history configuration setting
metadata: add historical_glv_remove
commands: lvremove: also process historical LVs
metadata: add vg_strip_outdated_historical_lvs fn and call it during VG read
conf: add metadata/lvs_history_timeout configuration setting
conf: regenerate example.conf.in
metadata: also look at historical LVs when checking LV name availability
metadata: also validate historical LVs in VG in vg_validate and check_lv_segments
metadata: automatically remove invalid (dangling) historical LVs
lvmdump: also list historical LVs in lvmdump
tests: add "get lvh_field" for "lvs -H"
tests: add lv-ancestry.sh test
commands: lvdisplay: recognize -H|--history switch
lvrename: support renaming historical logical volumes
cleanup: comment in the code for renaming historical LVs
man: lvrename: also mention possibility to rename historical logical volumes
WHATS_NEW: historical LVs
libdm: config: remove 4096 char limit due to buffer size if writing dm_config_node
cleanup: previous patch with libdm config node buffer size
libdm: config: fix dm_config_write_node and variants to properly return error on failures
Tony Asleson (1):
lvmdbusd: Set locale
Zdenek Kabelac (13):
coverity: missing error path
coverity: eliminate DEADCODE
cleanup: indent and dots
man: fix mising braces
makefile: handle dm-version-expected
cleanup: missplaced .
cache: add kernel_cache_policy option
man: lvconvert updates
man: minor updates
cleanup: use _field_string
cleanup: use lv_is_partial
tests: check kernel_cache_ funcs
tests: drop check for md5sum
8 years, 1 month
master - post-release
by Alasdair Kergon
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=7b15ca5c9ac364...
Commit: 7b15ca5c9ac3645b8d714014f89dbcd6731b2b04
Parent: 68ec240b99fca4e0860cb6e1b17ce4b888eb2585
Author: Alasdair G Kergon <agk(a)redhat.com>
AuthorDate: Fri Mar 4 18:06:24 2016 +0000
Committer: Alasdair G Kergon <agk(a)redhat.com>
CommitterDate: Fri Mar 4 18:06:24 2016 +0000
post-release
---
VERSION | 2 +-
VERSION_DM | 2 +-
WHATS_NEW | 3 +++
WHATS_NEW_DM | 3 +++
4 files changed, 8 insertions(+), 2 deletions(-)
diff --git a/VERSION b/VERSION
index 2b2c83e..4b10296 100644
--- a/VERSION
+++ b/VERSION
@@ -1 +1 @@
-2.02.145(2)-git (2016-03-04)
+2.02.146(2)-git (2016-03-04)
diff --git a/VERSION_DM b/VERSION_DM
index 6307cc1..3c381cc 100644
--- a/VERSION_DM
+++ b/VERSION_DM
@@ -1 +1 @@
-1.02.119-git (2016-03-04)
+1.02.120-git (2016-03-04)
diff --git a/WHATS_NEW b/WHATS_NEW
index 5452a0b..f29250e 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,3 +1,6 @@
+Version 2.02.146 -
+=================================
+
Version 2.02.145 - 4th March 2016
=================================
Make it possible to use lvremove and lvrename on historical LVs.
diff --git a/WHATS_NEW_DM b/WHATS_NEW_DM
index d54353d..4cdd97c 100644
--- a/WHATS_NEW_DM
+++ b/WHATS_NEW_DM
@@ -1,3 +1,6 @@
+Version 1.02.120 -
+=================================
+
Version 1.02.119 - 4th March 2016
=================================
Fix dm_config_write_node and variants to return error on subsection failures.
8 years, 1 month
master - pre-release
by Alasdair Kergon
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=68ec240b99fca4...
Commit: 68ec240b99fca4e0860cb6e1b17ce4b888eb2585
Parent: 6c781751261a6e75f8e3e63f5efbecf467d63476
Author: Alasdair G Kergon <agk(a)redhat.com>
AuthorDate: Fri Mar 4 17:59:21 2016 +0000
Committer: Alasdair G Kergon <agk(a)redhat.com>
CommitterDate: Fri Mar 4 17:59:21 2016 +0000
pre-release
---
VERSION | 2 +-
VERSION_DM | 2 +-
WHATS_NEW | 4 ++--
WHATS_NEW_DM | 4 ++--
4 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/VERSION b/VERSION
index 10d6493..2b2c83e 100644
--- a/VERSION
+++ b/VERSION
@@ -1 +1 @@
-2.02.145(2)-git (2016-02-26)
+2.02.145(2)-git (2016-03-04)
diff --git a/VERSION_DM b/VERSION_DM
index d930b03..6307cc1 100644
--- a/VERSION_DM
+++ b/VERSION_DM
@@ -1 +1 @@
-1.02.119-git (2016-02-26)
+1.02.119-git (2016-03-04)
diff --git a/WHATS_NEW b/WHATS_NEW
index cbdd14f..5452a0b 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,5 @@
-Version 2.02.145 -
-=====================================
+Version 2.02.145 - 4th March 2016
+=================================
Make it possible to use lvremove and lvrename on historical LVs.
For historical LVs, report 'none' for lv_layout and 'history' for lv_role.
Add full_{ancestors,descendants} fields to report LV ancestry with history.
diff --git a/WHATS_NEW_DM b/WHATS_NEW_DM
index 109249a..d54353d 100644
--- a/WHATS_NEW_DM
+++ b/WHATS_NEW_DM
@@ -1,5 +1,5 @@
-Version 1.02.119 -
-=====================================
+Version 1.02.119 - 4th March 2016
+=================================
Fix dm_config_write_node and variants to return error on subsection failures.
Remove 4096 char limit due to buffer size if writing dm_config_node.
8 years, 1 month
master - lvmdbusd: Set locale
by tasleson
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=6c781751261a6e...
Commit: 6c781751261a6e75f8e3e63f5efbecf467d63476
Parent: f94fe2c91fc995e2d57f7689f01d8d15d72858cc
Author: Tony Asleson <tasleson(a)redhat.com>
AuthorDate: Fri Mar 4 10:13:04 2016 -0600
Committer: Tony Asleson <tasleson(a)redhat.com>
CommitterDate: Fri Mar 4 10:13:04 2016 -0600
lvmdbusd: Set locale
Signed-off-by: Tony Asleson <tasleson(a)redhat.com>
---
daemons/lvmdbusd/main.py | 3 +++
1 files changed, 3 insertions(+), 0 deletions(-)
diff --git a/daemons/lvmdbusd/main.py b/daemons/lvmdbusd/main.py
index 6cabcc4..92006d0 100644
--- a/daemons/lvmdbusd/main.py
+++ b/daemons/lvmdbusd/main.py
@@ -103,6 +103,9 @@ def main():
use_session = os.getenv('LVMDBUSD_USE_SESSION', False)
+ # Ensure that we get consistent output for parsing stdout/stderr
+ os.environ["LC_ALL"] = "C"
+
args = parser.parse_args()
cfg.DEBUG = args.debug
8 years, 1 month
master - dbustest.sh: Get dbus test to work on buildbot
by tasleson
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=f94fe2c91fc995...
Commit: f94fe2c91fc995e2d57f7689f01d8d15d72858cc
Parent: 9720898c8ee3a4035858508b38179a143d948f4f
Author: Marian Csontos <mcsontos(a)redhat.com>
AuthorDate: Tue Feb 23 09:13:01 2016 +0100
Committer: Tony Asleson <tasleson(a)redhat.com>
CommitterDate: Fri Mar 4 10:11:03 2016 -0600
dbustest.sh: Get dbus test to work on buildbot
- stdout/stderr for test output
- debug.log* for daemon output
- use install instead of cp for DBus config
- use system bus
- DBus reloads on new file. Better having it created with correct
permissions.
Notes:
- Squashed commits from mcsontos development branch
- Still disabled at this time
Signed-off-by: Tony Asleson <tasleson(a)redhat.com>
---
test/api/dbustest.sh | 30 ++++++++++++++----------------
1 files changed, 14 insertions(+), 16 deletions(-)
diff --git a/test/api/dbustest.sh b/test/api/dbustest.sh
index b4e3964..ba3173e 100644
--- a/test/api/dbustest.sh
+++ b/test/api/dbustest.sh
@@ -21,18 +21,17 @@ skip
aux prepare_pvs 6
-# This allows us to run without installing
-# com.redhat.lvmdbus1.conf to /etc/dbus-1/system.d/
-# but in normal operation it needs to be on system bus
-export LVMDBUSD_USE_SESSION="True"
+# Copy the needed file to run on the system bus if it doesn't
+# already exist
+if [ ! -f /etc/dbus-1/system.d/com.redhat.lvmdbus1.conf ]; then
+ install -m 644 $abs_top_builddir/scripts/com.redhat.lvmdbus1.conf /etc/dbus-1/system.d/.
+fi
# Setup the python path so we can run
export PYTHONPATH=$abs_top_builddir/daemons
-# Where should we be logging the output of the daemon when not running as
-# a systemd service
# Start the dbus service
-$abs_top_builddir/daemons/lvmdbusd/lvmdbusd --debug --udev > /tmp/lvmdbusd.log 2>&1 &
+$abs_top_builddir/daemons/lvmdbusd/lvmdbusd --debug --udev > debug.log_lvmdbusd 2>&1 &
# Give the service some time to start before we try to run the
# unit test
@@ -45,17 +44,16 @@ if [ "CHK${LVM_DBUS_PID}" == "CHK" ];then
fi
# Run all the unit tests
-# Are we already logging stdout & stderror?
-$abs_top_builddir/test/dbus/lvmdbustest.py -v > /tmp/lvmdbustest.log 2>&1
+$abs_top_builddir/test/dbus/lvmdbustest.py -v || fail=$?
# We can run individual unit tests by doing this
# $abs_top_builddir/test/dbus/lvmdbustest.py -v TestDbusService.test_snapshot_merge
-# I'm guessing there is a better way to handle this with the built in test env.
-if [ $? -eq 0 ]; then
- rm -f /tmp/lvmdbusd.log
- rm -f /tmp/lvmdbustest.log
-fi
-
echo "Stopping service"
-kill $LVM_DBUS_PID
+kill $LVM_DBUS_PID || {
+ sleep 1
+ kill -9 $LVM_DBUS_PID
+}
+wait
+
+exit ${fail:-"0"}
8 years, 1 month
master - libdm: config: fix dm_config_write_node and variants to properly return error on failures
by Peter Rajnoha
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=9720898c8ee3a4...
Commit: 9720898c8ee3a4035858508b38179a143d948f4f
Parent: 67c5006e12c9e3bf888db0fbaa78a50efcbfa9b2
Author: Peter Rajnoha <prajnoha(a)redhat.com>
AuthorDate: Fri Mar 4 15:49:00 2016 +0100
Committer: Peter Rajnoha <prajnoha(a)redhat.com>
CommitterDate: Fri Mar 4 15:51:13 2016 +0100
libdm: config: fix dm_config_write_node and variants to properly return error on failures
The error was not propagated if _write_config (that is part of
dm_config_write_node and all its variants) was called recursively
for subsections.
---
WHATS_NEW_DM | 1 +
libdm/libdm-config.c | 3 ++-
2 files changed, 3 insertions(+), 1 deletions(-)
diff --git a/WHATS_NEW_DM b/WHATS_NEW_DM
index d3eac29..109249a 100644
--- a/WHATS_NEW_DM
+++ b/WHATS_NEW_DM
@@ -1,5 +1,6 @@
Version 1.02.119 -
=====================================
+ Fix dm_config_write_node and variants to return error on subsection failures.
Remove 4096 char limit due to buffer size if writing dm_config_node.
Version 1.02.118 - 26th February 2016
diff --git a/libdm/libdm-config.c b/libdm/libdm-config.c
index 5fa06a1..dcb7c3f 100644
--- a/libdm/libdm-config.c
+++ b/libdm/libdm-config.c
@@ -366,7 +366,8 @@ static int _write_config(const struct dm_config_node *n, int only_one,
line_append(" {");
if (!_line_end(n, out))
return_0;
- _write_config(n->child, 0, out, level + 1);
+ if (!_write_config(n->child, 0, out, level + 1))
+ return_0;
if (!_line_start(out))
return_0;
line_append("%s}", space);
8 years, 1 month
master - cleanup: previous patch with libdm config node buffer size
by Peter Rajnoha
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=67c5006e12c9e3...
Commit: 67c5006e12c9e3bf888db0fbaa78a50efcbfa9b2
Parent: 967a0889a024e2cc3f3afb3469e1b0657ebb85bc
Author: Peter Rajnoha <prajnoha(a)redhat.com>
AuthorDate: Fri Mar 4 15:19:09 2016 +0100
Committer: Peter Rajnoha <prajnoha(a)redhat.com>
CommitterDate: Fri Mar 4 15:19:09 2016 +0100
cleanup: previous patch with libdm config node buffer size
---
libdm/libdm-config.c | 12 +++++++-----
1 files changed, 7 insertions(+), 5 deletions(-)
diff --git a/libdm/libdm-config.c b/libdm/libdm-config.c
index a7f4096..5fa06a1 100644
--- a/libdm/libdm-config.c
+++ b/libdm/libdm-config.c
@@ -222,7 +222,7 @@ __attribute__ ((format(printf, 2, 3)))
static int _line_append(struct config_output *out, const char *fmt, ...)
{
char buf[4096];
- char *final_buf;
+ char *dyn_buf = NULL;
va_list ap;
int n;
@@ -246,21 +246,23 @@ static int _line_append(struct config_output *out, const char *fmt, ...)
* so try dynamically allocated buffer now...
*/
va_start(ap, fmt);
- n = dm_vasprintf(&final_buf, fmt, ap);
+ n = dm_vasprintf(&dyn_buf, fmt, ap);
va_end(ap);
if (n < 0) {
log_error("dm_vasprintf failed for config line");
return 0;
}
- } else
- final_buf = buf;
+ }
- if (!dm_pool_grow_object(out->mem, final_buf, strlen(final_buf))) {
+ if (!dm_pool_grow_object(out->mem, dyn_buf ? : buf, 0)) {
log_error("dm_pool_grow_object failed for config line");
+ dm_free(dyn_buf);
return 0;
}
+ dm_free(dyn_buf);
+
return 1;
}
8 years, 1 month
master - libdm: config: remove 4096 char limit due to buffer size if writing dm_config_node
by Peter Rajnoha
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=967a0889a024e2...
Commit: 967a0889a024e2cc3f3afb3469e1b0657ebb85bc
Parent: 418b7c6be8e553c04eeeb8a96d6b3d4b1da1bb9a
Author: Peter Rajnoha <prajnoha(a)redhat.com>
AuthorDate: Fri Mar 4 14:59:22 2016 +0100
Committer: Peter Rajnoha <prajnoha(a)redhat.com>
CommitterDate: Fri Mar 4 14:59:22 2016 +0100
libdm: config: remove 4096 char limit due to buffer size if writing dm_config_node
---
WHATS_NEW_DM | 1 +
libdm/libdm-config.c | 26 ++++++++++++++++++++++++--
2 files changed, 25 insertions(+), 2 deletions(-)
diff --git a/WHATS_NEW_DM b/WHATS_NEW_DM
index 174b6bd..d3eac29 100644
--- a/WHATS_NEW_DM
+++ b/WHATS_NEW_DM
@@ -1,5 +1,6 @@
Version 1.02.119 -
=====================================
+ Remove 4096 char limit due to buffer size if writing dm_config_node.
Version 1.02.118 - 26th February 2016
=====================================
diff --git a/libdm/libdm-config.c b/libdm/libdm-config.c
index 25f85e5..a7f4096 100644
--- a/libdm/libdm-config.c
+++ b/libdm/libdm-config.c
@@ -222,19 +222,41 @@ __attribute__ ((format(printf, 2, 3)))
static int _line_append(struct config_output *out, const char *fmt, ...)
{
char buf[4096];
+ char *final_buf;
va_list ap;
int n;
+ /*
+ * We should be fine with the 4096 char buffer 99% of the time,
+ * but if we need to go beyond that, allocate the buffer dynamically.
+ */
+
va_start(ap, fmt);
n = vsnprintf(&buf[0], sizeof buf - 1, fmt, ap);
va_end(ap);
- if (n < 0 || n > (int) sizeof buf - 1) {
+ if (n < 0) {
log_error("vsnprintf failed for config line");
return 0;
}
- if (!dm_pool_grow_object(out->mem, &buf[0], strlen(buf))) {
+ if (n > (int) sizeof buf - 1) {
+ /*
+ * Fixed size buffer with sizeof buf is not enough,
+ * so try dynamically allocated buffer now...
+ */
+ va_start(ap, fmt);
+ n = dm_vasprintf(&final_buf, fmt, ap);
+ va_end(ap);
+
+ if (n < 0) {
+ log_error("dm_vasprintf failed for config line");
+ return 0;
+ }
+ } else
+ final_buf = buf;
+
+ if (!dm_pool_grow_object(out->mem, final_buf, strlen(final_buf))) {
log_error("dm_pool_grow_object failed for config line");
return 0;
}
8 years, 1 month