mirror of
git://sourceware.org/git/lvm2.git
synced 2025-01-18 10:04:20 +03:00
cleanup: simplify pv name size estimation
Reuse buffer with size of 2 * PATH_MAX to handle worst case escape and avoid extra calculation of espaced len.
This commit is contained in:
parent
3fda296da6
commit
0499e87ace
@ -450,8 +450,7 @@ static int _print_pvs(struct formatter *f, struct volume_group *vg)
|
||||
{
|
||||
struct pv_list *pvl;
|
||||
struct physical_volume *pv;
|
||||
char buffer[4096];
|
||||
char *buf;
|
||||
char buffer[PATH_MAX * 2];
|
||||
const char *name;
|
||||
|
||||
outf(f, "physical_volumes {");
|
||||
@ -472,14 +471,13 @@ static int _print_pvs(struct formatter *f, struct volume_group *vg)
|
||||
|
||||
outf(f, "id = \"%s\"", buffer);
|
||||
|
||||
if (!(buf = alloca(dm_escaped_len(pv_dev_name(pv))))) {
|
||||
log_error("temporary stack allocation for device name"
|
||||
"string failed");
|
||||
if (strlen(pv_dev_name(pv)) >= PATH_MAX) {
|
||||
log_error("pv device name size is out of bounds.");
|
||||
return 0;
|
||||
}
|
||||
|
||||
outhint(f, "device = \"%s\"",
|
||||
dm_escape_double_quotes(buf, pv_dev_name(pv)));
|
||||
dm_escape_double_quotes(buffer, pv_dev_name(pv)));
|
||||
outnl(f);
|
||||
|
||||
if (!_print_flag_config(f, pv->status, PV_FLAGS))
|
||||
|
Loading…
x
Reference in New Issue
Block a user