Skip to contentSkip to conversation

LVM2/lib/cache lvmcache.c

PATCH [email protected] 1 participant 1 message Mar 13, 2011

lore
Share & tools
lore
#0 lore raw

CVSROOT: /cvs/lvm2
Module name: LVM2
Changes by: zkabelac at sourceware.org 2011-03-13 23:01:08

Modified files:
lib/cache : lvmcache.c

Log message:
Use proper size of strncpy

Avoid reading extra character if we expect to have there '\0'.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/cache/lvmcache.c.diff?cvsroot=lvm2&r1=1.106&r2=1.107

lib/cache/lvmcache.c +1 -1
@@ -1287,7 +1287,7 @@
 		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)) &&