From b76284afb1e2251b03a9d62a1cb5bde7f2255333 Mon Sep 17 00:00:00 2001 From: Osier Yang Date: Mon, 6 May 2013 20:45:11 +0800 Subject: [PATCH] util: Fix regression of wwn reading Introduced by commit 244ce462e29, which refactored the helper for wwn reading, however, it forgot to change the old "strndup" and "sizeof(buf)", "sizeof(buf)" operates on the fixed length array ("buf") in the old code, but now "buf" is a pointer. Before the fix: % virsh nodedev-dumpxml scsi_host5 scsi_host5 pci_0000_04_00_1 5 2001001b 2101001b 2001000d With the fix: % virsh nodedev-dumpxml scsi_host5 scsi_host5 pci_0000_04_00_1 5 0x2001001b32a9da4e 0x2101001b32a9da4e 0x2001000dec9877c1 --- src/util/virutil.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/util/virutil.c b/src/util/virutil.c index 3c0a48131d..39eeefb99e 100644 --- a/src/util/virutil.c +++ b/src/util/virutil.c @@ -1694,10 +1694,8 @@ virReadFCHost(const char *sysfs_prefix, else p = buf; - if (!(*result = strndup(p, sizeof(buf)))) { - virReportOOMError(); + if (VIR_STRDUP(*result, p) < 0) goto cleanup; - } ret = 0; cleanup: