CA-140391: check for overflow

Signed-off-by: Thanos Makatos <thanos.makatos@citrix.com>