[Libguestfs] [PATCH 1/8] New API: btrfs_subvolume_get_default
Richard W.M. Jones
rjones at redhat.com
Fri Dec 5 12:37:53 UTC 2014
On Fri, Dec 05, 2014 at 12:27:06PM +0000, Richard W.M. Jones wrote:
> On Tue, Dec 02, 2014 at 05:33:31PM +0800, Hu Tao wrote:
> > + ADD_ARG (argv, i, str_btrfs);
> > + ADD_ARG (argv, i, "subvolume");
> > + ADD_ARG (argv, i, "get-default");
> > + ADD_ARG (argv, i, fs_buf);
> > + ADD_ARG (argv, i, NULL);
> > +
> > + r = commandv (&out, &err, argv);
> > + if (r == -1) {
> > + reply_with_error ("%s: %s", mountpoint, err);
> > + return -1;
> > + }
> > + r = xstrtol (out + 2, NULL, 10, &ret, NULL);
>
> Unfortunately even gnulib's "xstrtol" function is a minefield, and the
> code above won't work [specifically -- it's insecure] on 32 bit
> machines.
>
> Anyway, I think it's better to use sscanf here, so:
>
> if (sscanf (out, "ID %" SCNi64, &ret) != 2) {
^^^^^
I mean != 1
Rich.
--
Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones
Read my programming and virtualization blog: http://rwmj.wordpress.com
virt-df lists disk usage of guests without needing to install any
software inside the virtual machine. Supports Linux and Windows.
http://people.redhat.com/~rjones/virt-df/
More information about the Libguestfs
mailing list