block/parallels: Avoid overflows
commit86d1bd70987cd11d85d01f52aa5824c63d910471
authorMax Reitz <mreitz@redhat.com>
Fri, 31 Mar 2017 17:05:12 +0000 (31 19:05 +0200)
committerMax Reitz <mreitz@redhat.com>
Mon, 3 Apr 2017 15:11:40 +0000 (3 17:11 +0200)
treee103c4b121c6b1d25c3b60cacb55ac3c2783697d
parentf82c5b17ea85d8f432069a4afd6cbdb65d9d8a66
block/parallels: Avoid overflows

Change the types of variables in allocate_clusters() to int64_t so we do
not have to worry about potential overflows.

Add an assertion that our accesses to s->bat[] do not result in a buffer
overflow and that the implicit conversion performed when invoking
bat_entry_off() does not result in an integer overflow.

Coverity-id: 1307776
Signed-off-by: Max Reitz <mreitz@redhat.com>
Message-id: 20170331170512.10381-1-mreitz@redhat.com
Reviewed-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Signed-off-by: Max Reitz <mreitz@redhat.com>
block/parallels.c