1
0
mirror of git://sourceware.org/git/lvm2.git synced 2024-12-21 13:34:40 +03:00

vgrename: use long enough buffer for path

Use PATH_MAX when creating buffers for rename.
This commit is contained in:
Zdenek Kabelac 2017-03-30 00:17:37 +02:00
parent 4b3d71212f
commit dfdd6ccf3b
3 changed files with 10 additions and 5 deletions

View File

@ -1,5 +1,6 @@
Version 2.02.170 -
==================================
Check and use PATH_MAX buffers when creating vgrename device paths.
Version 2.02.169 - 28th March 2017
==================================

View File

@ -377,7 +377,7 @@ static int _clog_ctr(char *uuid, uint64_t luid,
uint32_t block_on_error = 0;
int disk_log;
char disk_path[128];
char disk_path[PATH_MAX];
int unlink_path = 0;
long page_size;
int pages;

View File

@ -38,8 +38,8 @@ static int _vgrename_single(struct cmd_context *cmd, const char *vg_name,
struct volume_group *vg, struct processing_handle *handle)
{
struct vgrename_params *vp = (struct vgrename_params *) handle->custom_handle;
char old_path[NAME_LEN];
char new_path[NAME_LEN];
char old_path[PATH_MAX];
char new_path[PATH_MAX];
struct id id;
const char *name;
char *dev_dir;
@ -136,8 +136,12 @@ static int _vgrename_single(struct cmd_context *cmd, const char *vg_name,
goto error;
}
sprintf(old_path, "%s%s", dev_dir, vg_name);
sprintf(new_path, "%s%s", dev_dir, vp->vg_name_new);
if ((dm_snprintf(old_path, sizeof(old_path), "%s%s", dev_dir, vg_name) < 0) ||
(dm_snprintf(new_path, sizeof(new_path), "%s%s", dev_dir, vp->vg_name_new) < 0)) {
log_error("Renaming path is too long %s/%s %s/%s",
dev_dir, vg_name, dev_dir, vp->vg_name_new);
goto error;
}
if (activation() && dir_exists(old_path)) {
log_verbose("Renaming \"%s\" to \"%s\"", old_path, new_path);