From a064168869792934f3a0910f71705b49aff27cde Mon Sep 17 00:00:00 2001 From: Michael Lotz Date: Sat, 27 Apr 2013 17:59:24 +0200 Subject: [PATCH] Fix truncation of comparison value introduced in 848acd67. Casting the difference of the two off_t values to size_t may truncate the result. Doing so before the comparison will therefore break it. Instead cast the size to off_t to get around the signed versus unsigned integer expression comparison and then cast the result of the comparison to size_t again. Should fix #9714. --- src/system/kernel/device_manager/devfs.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/system/kernel/device_manager/devfs.cpp b/src/system/kernel/device_manager/devfs.cpp index 7cc1ebcc90..ca77751768 100644 --- a/src/system/kernel/device_manager/devfs.cpp +++ b/src/system/kernel/device_manager/devfs.cpp @@ -487,7 +487,7 @@ translate_partition_access(devfs_partition* partition, off_t& offset, ASSERT(offset >= 0); ASSERT(offset < partition->info.size); - size = min_c(size, (size_t)(partition->info.size - offset)); + size = (size_t)min_c((off_t)size, partition->info.size - offset); offset += partition->info.offset; }