master - vgrename: use long enough buffer for path
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=dfdd6ccf3be73a2b22743ea1df31cd3d7e3c9095 Commit: dfdd6ccf3be73a2b22743ea1df31cd3d7e3c9095 Parent: 4b3d71212fb07c945acebb074820a63e970504e5 Author: Zdenek Kabelac <[email protected]> AuthorDate: Thu Mar 30 00:17:37 2017 +0200 Committer: Zdenek Kabelac <[email protected]> CommitterDate: Thu Mar 30 00:38:41 2017 +0200
vgrename: use long enough buffer for path
Use PATH_MAX when creating buffers for rename.
--- WHATS_NEW | 1 + daemons/cmirrord/functions.c | 2 +- tools/vgrename.c | 12 ++++++++---- 3 files changed, 10 insertions(+), 5 deletions(-)
WHATS_NEW +1 -0
@@ -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 ==================================
daemons/cmirrord/functions.c +1 -1
@@ -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;
tools/vgrename.c +8 -4
@@ -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);