[Libguestfs] [PATCH v2 2/2] GCC 7: Allocate sufficient space for sprintf output.

Pino Toscano ptoscano at redhat.com
Tue Feb 14 16:55:19 UTC 2017


On Tuesday, 14 February 2017 16:51:23 CET Richard W.M. Jones wrote:
> diff --git a/daemon/9p.c b/daemon/9p.c
> index a9e36d1..f72c8dd 100644
> --- a/daemon/9p.c
> +++ b/daemon/9p.c
> @@ -71,9 +71,13 @@ do_list_9p (void)
>      if (d == NULL) break;
>  
>      if (STRPREFIX (d->d_name, "virtio")) {
> -      char mount_tag_path[256];
> -      snprintf (mount_tag_path, sizeof mount_tag_path,
> -                BUS_PATH "/%s/mount_tag", d->d_name);
> +      CLEANUP_FREE char *mount_tag_path;

I'd initialize this (and all the other occurrences in this patch) to
NULL anyway, so if in the future more code is added between the
declaration and the initialization then there's no risk.

LGTM with the above changes.

-- 
Pino Toscano
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: This is a digitally signed message part.
URL: <http://listman.redhat.com/archives/libguestfs/attachments/20170214/7d9a94fb/attachment.sig>


More information about the Libguestfs mailing list