memslot: Fix off-by-one error in group/slot boundary check

RedMemSlotInfo keeps an array of groups, and each group contains an
array of slots. Unfortunately, these checks are off by 1, they check
that the index is greater or equal to the number of elements in the
array, while these arrays are 0 based. The check should only check for
strictly greater than the number of elements.

For the group array, this is not a big issue, as these memslot groups
are created by spice-server users (eg QEMU), and the group ids used to
index that array are also generated by the spice-server user, so it
should not be possible for the guest to set them to arbitrary values.

The slot id is more problematic, as it's calculated from a QXLPHYSICAL
address, and such addresses are usually set by the guest QXL driver, so
the guest can set these to arbitrary values, including malicious values,
which are probably easy to build from the guest PCI configuration.

This patch fixes the arrays bound check, and adds a test case for this.
This fixes CVE-2019-3813.

Signed-off-by: Christophe Fergeau <cfergeau@redhat.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
8 jobs for master in 42 minutes and 18 seconds (queued for 7 minutes and 31 seconds)
Status Job ID Name Coverage
  Test
passed #99510
check-valgrind

00:11:10

passed #99512
distcheck

00:06:16

passed #99506
makecheck

00:07:07

passed #99513
makecheck-centos

00:05:37

passed #99507
meson-makecheck

00:03:40

passed #99509
meson-options

00:02:36

passed #99508
options

00:05:38

passed #99511
syntax-check

00:11:30