[libvirt] [PATCH 1/7] util: Fix regression of wwn reading

Eric Blake eblake at redhat.com
Wed May 8 22:54:59 UTC 2013


On 05/06/2013 06:45 AM, Osier Yang wrote:
> 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.
> 

> +++ b/src/util/virutil.c
> @@ -3121,7 +3121,7 @@ virReadFCHost(const char *sysfs_prefix,
>      else
>          p = buf;
>  
> -    if (!(*result = strndup(p, sizeof(buf)))) {
> +    if (!(*result = strdup(p))) {
>          virReportOOMError();

Now that we have it, I'd write this as:

if (VIR_STRDUP(result, p) < 0)
    goto cleanup;

Of course, when backporting to v1.0.5-maint, you'll have to use the
long-hand (unless we backport VIR_STRDUP first).

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 621 bytes
Desc: OpenPGP digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20130508/dc0a8629/attachment-0001.sig>


More information about the libvir-list mailing list