From: Osier Yang Date: Mon, 6 May 2013 12:45:11 +0000 (+0800) Subject: util: Fix regression of wwn reading X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=b76284afb1e2251b03a9d62a1cb5bde7f2255333;p=libvirt.git 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 --- 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: