> From: Kozak, KubaX
> Sent: Tuesday, May 9, 2017 6:23 AM
> To: [email protected]
> Cc: Van Haaren, Harry <[email protected]>; Jain, Deepak K 
> <[email protected]>;
> Jastrzebski, MichalX K <[email protected]>; Kozak, KubaX 
> <[email protected]>
> Subject: [PATCH] proc-info: wrong sizeof argument in malloc function
> 
> From: Michal Jastrzebski <[email protected]>
> 
> Coverity reported that an argument for sizeof was used improperly.
> We should allocate memory for value size that pointer points to,
> instead of pointer size itself.
> 
> Coverity issue: 144523, 144521
> Fixes: 7ac16a3660c0 ("app/proc-info: support xstats by ID and by name")
> 
> Signed-off-by: Michal Jastrzebski <[email protected]>


Please consider merging these in 17.05, this is an important fix for 32 bit 
systems.

Acked-by: Harry van Haaren <[email protected]>



Details:
64 bit system: sizeof(uint64_t*) == sizeof(uint64_t)
32 bit system: sizeof(uint64_t*) != sizeof(uint64_t)

uint64_t *values;

> -     values = malloc(sizeof(values) * len);
> +     values = malloc(sizeof(*values) * len);

The change here ensures that we allocate sizeof(uint64_t) * len, instead of the 
incorrect sizeof(void *) * len.

Previously on 32 bit systems, only half of the memory required would be 
allocated.

Reply via email to