Try to avoid integer overflow when reading a corrupted binary datafile
with sadf.
Signed-off-by: Sebastien GODARD <sysstat@users.noreply.github.com>
/* Remap [unsigned] int fields */
d = gtypes_nr[1] - ftypes_nr[1];
if (d) {
- if (ftypes_nr[1] * UL_ALIGNMENT_WIDTH < ftypes_nr[1])
+ if (gtypes_nr[0] * ULL_ALIGNMENT_WIDTH +
+ ftypes_nr[1] * UL_ALIGNMENT_WIDTH < ftypes_nr[1])
/* Overflow */
return -1;
/* Remap possible fields (like strings of chars) following int fields */
d = gtypes_nr[2] - ftypes_nr[2];
if (d) {
- if (ftypes_nr[2] * U_ALIGNMENT_WIDTH < ftypes_nr[2])
+ if (gtypes_nr[0] * ULL_ALIGNMENT_WIDTH +
+ gtypes_nr[1] * UL_ALIGNMENT_WIDTH +
+ ftypes_nr[2] * U_ALIGNMENT_WIDTH < ftypes_nr[2])
/* Overflow */
return -1;