From: "Marc Marí" <marc.mari.barcelo@gmail.com>
To: Fam Zheng <famz@redhat.com>
Cc: Paolo Bonzini <pbonzini@redhat.com>,
qemu-devel@nongnu.org, Stefan Hajnoczi <stefanha@redhat.com>
Subject: Re: [Qemu-devel] [RFC] Functions bus_foreach and device_find from libqos virtio API
Date: Tue, 24 Jun 2014 10:11:44 +0200 [thread overview]
Message-ID: <20140624101144.135f8095@crunchbang> (raw)
In-Reply-To: <20140624060517.GA4490@T430.redhat.com>
Hello
> > -/* Tests only initialization so far. TODO: Replace with functional
> > tests */ -static void pci_nop(void)
> > +#define TEST_IMAGE_SIZE (64 * 1024 * 1024)
> > +
> > +static char tmp_path[] = "/tmp/qtest.XXXXXX";
> > +extern QVirtioBus qvirtio_pci;
> > +
> > +static void pci_basic(void)
> > {
> > + QVirtioDevice *dev;
> > + dev = qvirtio_pci.device_find(VIRTIO_BLK_DEVICE_ID);
> > + fprintf(stderr, "Device: %x %x %x\n",
> > + dev->device_id, dev->location,
> > dev->device_type); }
> >
> > int main(int argc, char **argv)
> > {
> > int ret;
> > + int fd;
> > + char test_start[100];
>
> Depending on length of tmp_path, this looks quite close to an
> overflow ...
>
> >
> > g_test_init(&argc, &argv, NULL);
> > - qtest_add_func("/virtio/blk/pci/nop", pci_nop);
> > + qtest_add_func("/virtio/blk/pci/basic", pci_basic);
> >
> > - qtest_start("-drive id=drv0,if=none,file=/dev/null "
> > - "-device virtio-blk-pci,drive=drv0");
> > + /* Create a temporary raw image */
> > + fd = mkstemp(tmp_path);
> > + g_assert_cmpint(fd, >=, 0);
> > + ret = ftruncate(fd, TEST_IMAGE_SIZE);
> > + g_assert_cmpint(ret, ==, 0);
> > + close(fd);
> > +
> > + sprintf(test_start, "-drive if=none,id=drive0,file=%s "
> > + "-device virtio-blk-pci,drive=drive0",
> > tmp_path);
>
> ... here. Also please use snprintf.
>
tmp_path is defined as global, and has always the same size
(/tmp/qtest.XXXXXX, where the X will be replaced by a temporary name).
But I'll change to snprintf for security.
prev parent reply other threads:[~2014-06-24 8:12 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-06-23 14:55 [Qemu-devel] [RFC] Functions bus_foreach and device_find from libqos virtio API Marc Marí
2014-06-24 4:41 ` Stefan Hajnoczi
2014-06-24 8:02 ` Marc Marí
2014-06-24 6:05 ` Fam Zheng
2014-06-24 8:11 ` Marc Marí [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20140624101144.135f8095@crunchbang \
--to=marc.mari.barcelo@gmail.com \
--cc=famz@redhat.com \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=stefanha@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).