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

Re: [Libguestfs] [PATCHv2] Added btrfs support for vfs_min_size.



On Fri, Oct 23, 2015 at 07:53:58PM +0300, Maxim Perevedentsev wrote:
> --- a/daemon/fs-min-size.c
> +++ b/daemon/fs-min-size.c
> @@ -18,19 +18,35 @@
> 
>  #include <config.h>
> 
> -#include <stdio.h>
> -#include <stdlib.h>
> -#include <unistd.h>
> -

Not sure why these were removed.  Almost any file should include
<stdio.h> and probably <stdlib.h>.

<unistd.h> is needed for most system calls.  Also <string.h> is needed
in this file because it calls strdup.

Don't depend on implicit #includes in "daemon.h".

> +  for (i = 0; mountpoints[i] != NULL; i += 2) {
> +    if (STREQ (mountpoints[i], device))
> +      return strdup (mountpoints[i + 1]);

You need to check the return value of strdup in case there was an
allocation error.  The mountpoints string is (to some extent) under
end-user control, and if the call to strdup were to return NULL
libguestfs would hang.

Also 'daemon/btrfs.c' has a rogue newline at the end of the file,
which git complains about.

Rich.

-- 
Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones
Read my programming and virtualization blog: http://rwmj.wordpress.com
virt-builder quickly builds VMs from scratch
http://libguestfs.org/virt-builder.1.html


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