1
0
mirror of git://sourceware.org/git/lvm2.git synced 2025-01-03 05:18:29 +03:00

coverity: validate length of renaming path

Make sure path fits into buffer on stack.
This commit is contained in:
Zdenek Kabelac 2017-06-27 11:37:24 +02:00
parent 8e790702f1
commit 419e8284c8

View File

@ -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);