1
0
mirror of git://sourceware.org/git/lvm2.git synced 2025-08-02 04:22:02 +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 c9c1730705
commit e1cb521dd9

View File

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