master - coverity: validate length of renaming path
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=419e8284c8b918558b20bc1e2194ad2cbdd5d58b Commit: 419e8284c8b918558b20bc1e2194ad2cbdd5d58b Parent: 8e790702f12ddcb730f8dc43d3fdccf08e62aa45 Author: Zdenek Kabelac <[email protected]> AuthorDate: Tue Jun 27 11:37:24 2017 +0200 Committer: Zdenek Kabelac <[email protected]> CommitterDate: Tue Jun 27 12:15:42 2017 +0200
coverity: validate length of renaming path
Make sure path fits into buffer on stack.
--- lib/format_text/format-text.c | 5 +++++ 1 files changed, 5 insertions(+), 0 deletions(-)
lib/format_text/format-text.c +5 -0
@@ -1043,6 +1043,11 @@ static int _vg_commit_file(struct format_instance *fid, struct volume_group *vg,if (strcmp (slash, vg->name)) { len = slash - tc->path_live; +if ((len +strlen (vg->name)) > (sizeof (new_name) -1 )) { +log_error ("Renaming path %s is too long for VG %s." , + tc->path_live, vg->name); +return 0 ; + }strncpy (new_name, tc->path_live, len);strcpy (new_name + len, vg->name);log_debug_metadata ("Renaming %s to %s" , tc->path_live, new_name);