diff options
author | Jes Sorensen <jsorensen@fb.com> | 2018-05-30 18:10:13 +0200 |
---|---|---|
committer | Jes Sorensen <jsorensen@fb.com> | 2018-05-30 18:10:13 +0200 |
commit | ebad3af29b401dec7203e8fa5a77bcf16532f49c (patch) | |
tree | 04e61bdfdfc5d5064e7d4782205d42c33e282122 | |
parent | super-intel: Avoid gcc-8.1 complaining about truncating snprintf() (diff) | |
download | mdadm-ebad3af29b401dec7203e8fa5a77bcf16532f49c.tar.xz mdadm-ebad3af29b401dec7203e8fa5a77bcf16532f49c.zip |
super-intel: Do not truncate last character of volume name
Clear up strncpy abuse to avoid gcc-8.1 complaining about truncating
the string.
Signed-off-by: Jes Sorensen <jsorensen@fb.com>
-rw-r--r-- | super-intel.c | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/super-intel.c b/super-intel.c index 520d2921..aa93a9e9 100644 --- a/super-intel.c +++ b/super-intel.c @@ -7587,11 +7587,12 @@ static int update_subarray_imsm(struct supertype *st, char *subarray, append_metadata_update(st, u, sizeof(*u)); } else { struct imsm_dev *dev; - int i; + int i, namelen; dev = get_imsm_dev(super, vol); - strncpy((char *) dev->volume, name, MAX_RAID_SERIAL_LEN); - dev->volume[MAX_RAID_SERIAL_LEN-1] = '\0'; + memset(dev->volume, '\0', MAX_RAID_SERIAL_LEN); + namelen = min((int)strlen(name), MAX_RAID_SERIAL_LEN); + memcpy(dev->volume, name, namelen); for (i = 0; i < mpb->num_raid_devs; i++) { dev = get_imsm_dev(super, i); handle_missing(super, dev); |