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

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



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

Attachment: signature.asc
Description: OpenPGP digital signature


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