From: xie xingguo Date: Wed, 8 Jun 2016 06:30:30 +0000 (+0800) Subject: client: fix potential access violation X-Git-Tag: v11.0.0~188^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=411fa253d0d5047ea9d0313c54328d5755b77205;p=ceph.git client: fix potential access violation The _read() call may fail and return a negative result, and thus when it is passed to "resid", which is of type of "unsigned", overflow happens due to a forced cast that is implicitly performed. Signed-off-by: xie xingguo --- diff --git a/src/client/Client.cc b/src/client/Client.cc index 31cc936bce8d..98041d2b130a 100644 --- a/src/client/Client.cc +++ b/src/client/Client.cc @@ -8273,6 +8273,9 @@ int Client::_preadv_pwritev(int fd, const struct iovec *iov, unsigned iovcnt, in bufferlist bl; int r = _read(fh, offset, totallen, &bl); ldout(cct, 3) << "preadv(" << fd << ", " << offset << ") = " << r << dendl; + if (r <= 0) + return r; + int bufoff = 0; for (unsigned j = 0, resid = r; j < iovcnt && resid > 0; j++) { /*