From: Jonathan Rajotte Date: Thu, 27 Jan 2022 19:22:22 +0000 (-0500) Subject: Fix: conversion from KB to bytes overflow on arm32 X-Git-Url: https://git.liburcu.org/?a=commitdiff_plain;h=13dd7782d52be2dac47be5116c00d3a2ba0ad626;hp=13dd7782d52be2dac47be5116c00d3a2ba0ad626;p=lttng-tools.git Fix: conversion from KB to bytes overflow on arm32 Observed issue ============== On enable channel the memory available check fails on arm32 when available memory, in bytes, is larger than 2^32. Cause ===== `read_proc_meminfo_field` converts the read value (in KB) to bytes and stores it into a size_t variable. On the system running the reproducer the value of the `value_kb` variable is 4839692, yielding an overflow when multiplied with 1024 since `size_t` is 32 bit long. `size_t` can be larger in certain situation (i.e LARGEFILE) but this is irrelevant to the problem at hand. Solution ======== Convert all the checks to use uint64_t. Known drawbacks ========= None. References ========== The multiplication overflow check scheme is borrowed from `src/common/time.c` Signed-off-by: Jonathan Rajotte Signed-off-by: Jérémie Galarneau Change-Id: I067da25659ab4115e5494e48aab45a1c35f56652 ---