From 435fa6d7098769e36c840a4a53b5e0a9b9c4bdcc Mon Sep 17 00:00:00 2001 From: Chris Lalancette Date: Fri, 30 Jul 2010 10:19:51 -0400 Subject: [PATCH] Fix DMI uuid parsing. valgrind was complaining that virUUIDParse was depending on an uninitialized value. Indeed it was; virSetHostUUIDStr() didn't initialize the dmiuuid buffer to 0's, meaning that anything after the string read from /sys was uninitialized. Clear out the dmiuuid buffer before use, and make sure to always leave a \0 at the end. Signed-off-by: Chris Lalancette --- src/util/uuid.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/util/uuid.c b/src/util/uuid.c index f18814885e..9cafc2ada1 100644 --- a/src/util/uuid.c +++ b/src/util/uuid.c @@ -286,7 +286,8 @@ virSetHostUUIDStr(const char *uuid) return EEXIST; if (!uuid) { - if (!getDMISystemUUID(dmiuuid, sizeof(dmiuuid))) { + memset(dmiuuid, 0, sizeof(dmiuuid)); + if (!getDMISystemUUID(dmiuuid, sizeof(dmiuuid) - 1)) { if (!virUUIDParse(dmiuuid, host_uuid)) return 0; }