[libblockdev 1/2] Omit i < NUM_PREFIXES check.
mulhern
amulhern at redhat.com
Wed Sep 3 02:13:14 UTC 2014
Because the size we are dealing with is an unsigned 64 bit integer
the maximum representable value is 2^64 - 1 which means that
INT_LT_FLOAT(1024, value) must be false when i is 6. Therefore, i
can never reach NUM_PREFIXES, i.e., 7, so the check is pointless.
If i could reach NUM_PREFIXES then there would exist a path such that
i was 7 when size_prefixes[i] is evaluated, which would be an
access outside the bounds of the array.
Signed-off-by: mulhern <amulhern at redhat.com>
---
src/utils/sizes.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/utils/sizes.c b/src/utils/sizes.c
index d4eb622..0c5c504 100644
--- a/src/utils/sizes.c
+++ b/src/utils/sizes.c
@@ -37,7 +37,7 @@ gchar* bd_utils_size_human_readable (guint64 size) {
gdouble value = (gdouble) size;
gdouble prev_value = (gdouble) value;
- for (i=0; i < NUM_PREFIXES && INT_LT_FLOAT(1024, value); i++) {
+ for (i=0; INT_LT_FLOAT(1024, value); i++) {
prev_value = value;
value = value / 1024.0;
}
--
1.9.3
More information about the anaconda-patches
mailing list