[Pdbg] [PATCH] putmem: Fix Floating point exception issue

Alistair Popple alistair at popple.id.au
Thu Jul 12 15:35:44 AEST 2018


Thanks Vasant,

On Thursday, 5 July 2018 8:11:15 PM AEST Vasant Hegde wrote:
> Validate read() before calling __adu_putmem().
> Also check end size in progress_tick().

These should really be split into two patches. I have taken the first hunk of
this patch which validates the read and prevents the floating point exception.
There are a few comments on the second hunk which really needs to be submitted
as a seperate patch. Thanks!

> diff --git a/src/progress.c b/src/progress.c
> index fe443b9..e57b8de 100644
> --- a/src/progress.c
> +++ b/src/progress.c
> @@ -51,6 +51,9 @@ void progress_tick(uint64_t cur, uint64_t end)
>  	uint64_t pcent;
>  	double sec;
>  
> +	if (end == 0)
> +		return;

IMHO calling progress_tick() with cur > end or end == 0 is a programming error
and not something which should just be ignored. We shouldn't segfault either
though so we should add an assert statement to validate the arguments.

eg:
	assert(cur <= end && end);

Note that this will also require a fix in __adu_putmem() where we call
pdbg_progress_tick(size, size);

- Alistair

>  	pcent = (cur * 100) / end;
>  	if (progress_pcent == pcent && cur < progress_n_upd &&
>  	    cur < end)
> 




More information about the Pdbg mailing list