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

Use proper size of strncpy

Avoid reading extra character if we expect to have there '\0'.
This commit is contained in:
Zdenek Kabelac 2011-03-13 23:01:08 +00:00
parent 77e3ec4e28
commit d8d824c6c5

View File

@ -1287,7 +1287,7 @@ struct lvmcache_info *lvmcache_add(struct labeller *labeller, const char *pvid,
return NULL;
}
strncpy(pvid_s, pvid, sizeof(pvid_s));
strncpy(pvid_s, pvid, sizeof(pvid_s) - 1);
pvid_s[sizeof(pvid_s) - 1] = '\0';
if (!(existing = info_from_pvid(pvid_s, 0)) &&