[Pdbg] [PATCH] libpdbg: Fix segfault when auto-detecting host backend

Amitay Isaacs amitay at ozlabs.org
Mon Oct 14 16:12:34 AEDT 2019


On Mon, 2019-10-14 at 13:26 +1100, Alistair Popple wrote:
> A NULL-dereference causes a segfault when running on the host with no
> backend specified. Instead the backend should be auto-detected.
> 
> Signed-off-by: Alistair Popple <alistair at popple.id.au>
> ---
>  libpdbg/dtb.c | 10 ++++++----
>  1 file changed, 6 insertions(+), 4 deletions(-)
> 
> diff --git a/libpdbg/dtb.c b/libpdbg/dtb.c
> index 53e9b73..c0fb374 100644
> --- a/libpdbg/dtb.c
> +++ b/libpdbg/dtb.c
> @@ -83,10 +83,12 @@ static void *ppc_target(void)
>  	char line[256];
>  	FILE *cpuinfo;
>  
> -	if (!strcmp(pdbg_backend_option, "p8"))
> -		return &_binary_p8_host_dtb_o_start;
> -	else if (!strcmp(pdbg_backend_option, "p9"))
> -		return &_binary_p9_host_dtb_o_start;
> +	if (pdbg_backend_option) {
> +		if (!strcmp(pdbg_backend_option, "p8"))
> +			return &_binary_p8_host_dtb_o_start;
> +		else if (!strcmp(pdbg_backend_option, "p9"))
> +			return &_binary_p9_host_dtb_o_start;
> +	}
>  
>  	cpuinfo = fopen("/proc/cpuinfo", "r");
>  	if (!cpuinfo)
> -- 
> 2.20.1
> 

I have this fixed in my patch set.  Are we ready to merge my patch set
yet? Or do you want do another release with this fix before merging
system device tree stuff?

Amitay.
-- 

Only two things are infinite, the universe and human stupidity, and
I'm not sure about the former.  -- Albert Einstein



More information about the Pdbg mailing list