[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[lvm-devel] LVM2/lib/config config.c



CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	zkabelac sourceware org	2011-01-28 10:19:00

Modified files:
	lib/config     : config.c 

Log message:
	Use memcpy and add error message
	
	strncpy (which check each byte for \0) is not need as we always copy
	the length size - so using memcpy is a bit cheaper.
	
	Add missing log_error message for failed allocation.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/config/config.c.diff?cvsroot=lvm2&r1=1.87&r2=1.88

--- LVM2/lib/config/config.c	2010/12/20 13:53:11	1.87
+++ LVM2/lib/config/config.c	2011/01/28 10:19:00	1.88
@@ -886,9 +886,11 @@
 {
 	size_t len = p->te - p->tb;
 	char *str = dm_pool_alloc(p->mem, len + 1);
-	if (!str)
-		return_0;
-	strncpy(str, p->tb, len);
+	if (!str) {
+		log_error("Failed to duplicate token.");
+		return 0;
+	}
+	memcpy(str, p->tb, len);
 	str[len] = '\0';
 	return str;
 }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]