Skip to content

Commit

Permalink
snapshots: fix coverity issue (gluster#3050)
Browse files Browse the repository at this point in the history
Fixing copy into fixed size buffer

CID: 1467251, 1467255
Updates: gluster#1060

Change-Id: I25ca2aef7099be87ae133338db91a90a40085446
Signed-off-by: Tamar Shacked <[email protected]>
  • Loading branch information
tshacked authored Dec 20, 2021
1 parent 9e8bbd0 commit 166bed1
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
9 changes: 6 additions & 3 deletions xlators/mgmt/glusterd/src/glusterd-snapshot-utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -1042,7 +1042,8 @@ gd_import_volume_snap_details(dict_t *dict, glusterd_volinfo_t *volinfo,
"for %s",
key, volname);
} else
strcpy(volinfo->restored_from_snapname_id, restored_snapname_id);
gf_strncpy(volinfo->restored_from_snapname_id, restored_snapname_id,
sizeof(volinfo->restored_from_snapname_id));

snprintf(key, sizeof(key), "%s.restored_from_snapname", prefix);
ret = dict_get_str(dict, key, &restored_snapname);
Expand All @@ -1052,7 +1053,8 @@ gd_import_volume_snap_details(dict_t *dict, glusterd_volinfo_t *volinfo,
"for %s",
key, volname);
} else
strcpy(volinfo->restored_from_snapname, restored_snapname);
gf_strncpy(volinfo->restored_from_snapname, restored_snapname,
sizeof(volinfo->restored_from_snapname));

snprintf(key, sizeof(key), "%s.snap_plugin", prefix);
ret = dict_get_str(dict, key, &snap_plugin);
Expand All @@ -1062,7 +1064,8 @@ gd_import_volume_snap_details(dict_t *dict, glusterd_volinfo_t *volinfo,
"for %s",
key, volname);
} else
strcpy(volinfo->snap_plugin, snap_plugin);
gf_strncpy(volinfo->snap_plugin, snap_plugin,
sizeof(volinfo->snap_plugin));

snprintf(key, sizeof(key), "%s.snap-max-hard-limit", prefix);
ret = dict_get_uint64(dict, key, &volinfo->snap_max_hard_limit);
Expand Down
3 changes: 2 additions & 1 deletion xlators/mgmt/glusterd/src/glusterd-snapshot.c
Original file line number Diff line number Diff line change
Expand Up @@ -4611,7 +4611,8 @@ glusterd_take_brick_snapshot(dict_t *dict, glusterd_volinfo_t *snap_vol,
"snap_plugin");
goto out;
}
strcpy(snap_vol->snap_plugin, snap_plugin);
gf_strncpy(snap_vol->snap_plugin, snap_plugin,
sizeof(snap_vol->snap_plugin));
glusterd_snapshot_plugin_by_name(snap_plugin, &snap_ops);
ret = snap_ops->create(brickinfo, snap_vol->snapshot->snapname,
snap_volume_id, brick_count);
Expand Down

0 comments on commit 166bed1

Please sign in to comment.