From: Peter Lieven Date: Sat, 15 Mar 2014 14:58:08 +0000 (+0100) Subject: fix possible wrong cast to 32-bit unsigned X-Git-Tag: upstream/1.9.6^2~76^2~4 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=d485997ad37be6ac5f1e89f4e6b2cb68921ce193;p=deb_libnfs.git fix possible wrong cast to 32-bit unsigned when calculation the max_offset the (unsigned) leads to a cast to a 32-bit unsigned integer depending on the platform. as a result we update the max_offset everytime when it grows beyond 2^32. this leads to a wrong return max_offset value if the callbacks are received out of order. Signed-off-by: Peter Lieven --- diff --git a/lib/libnfs.c b/lib/libnfs.c index 937cb9d..8506795 100644 --- a/lib/libnfs.c +++ b/lib/libnfs.c @@ -1598,7 +1598,7 @@ static void nfs_pread_mcb(struct rpc_context *rpc, int status, void *command_dat if (res->READ3res_u.resok.count > 0) { if (res->READ3res_u.resok.count <= mdata->count) { memcpy(&data->buffer[mdata->offset - data->start_offset], res->READ3res_u.resok.data.data_val, res->READ3res_u.resok.count); - if ((unsigned)data->max_offset < mdata->offset + res->READ3res_u.resok.count) { + if (data->max_offset < mdata->offset + res->READ3res_u.resok.count) { data->max_offset = mdata->offset + res->READ3res_u.resok.count; } } else { @@ -1807,7 +1807,7 @@ static void nfs_pwrite_mcb(struct rpc_context *rpc, int status, void *command_da data->error = 1; } else { if (res->WRITE3res_u.resok.count > 0) { - if ((unsigned)data->max_offset < mdata->offset + res->WRITE3res_u.resok.count) { + if (data->max_offset < mdata->offset + res->WRITE3res_u.resok.count) { data->max_offset = mdata->offset + res->WRITE3res_u.resok.count; } }