From d485997ad37be6ac5f1e89f4e6b2cb68921ce193 Mon Sep 17 00:00:00 2001 From: Peter Lieven Date: Sat, 15 Mar 2014 15:58:08 +0100 Subject: [PATCH] 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 --- lib/libnfs.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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; } } -- 2.34.1