]> xenbits.xensource.com Git - qemu-xen-4.6-testing.git/commit
cpu_ioreq_pio, cpu_ioreq_move: introduce read_phys_req_item, write_phys_reqm
authorIan Jackson <ian.jackson@eu.citrix.com>
Wed, 20 Feb 2013 15:40:13 +0000 (15:40 +0000)
committerIan Jackson <Ian.Jackson@eu.citrix.com>
Wed, 20 Feb 2013 15:40:13 +0000 (15:40 +0000)
commit3b7917bce51cdf433924d295edcfe84f407bd1f7
tree63ef7bb4b875ebfb3a8a9cb0c48d9cdb09e622ae
parent2a1354d655d816feaad7dbdb8364f40a208439c1
cpu_ioreq_pio, cpu_ioreq_move: introduce read_phys_req_item, write_phys_reqm

The current code compare i (int) with req->count (uint32_t) in a for
loop, risking an infinite loop if req->count is >INT_MAX.  It also
does the multiplication of req->size in a too-small type, leading to
integer overflows.

Turn read_physical and write_physical into two different helper
functions, read_phys_req_item and write_phys_req_item, that take care
of adding or subtracting offset depending on sign.

This removes the formulaic multiplication to a single place where the
integer overflows can be dealt with by casting to wide-enough unsigned
types.

Reported-By: Dongxiao Xu <dongxiao.xu@intel.com>
Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
Tested-by: Dongxiao Xu <dongxiao.xu@intel.com>
i386-dm/helper2.c