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

Alistair Popple alistair at popple.id.au
Mon Oct 14 16:16:16 AEDT 2019


On Monday, 14 October 2019 4:12:34 PM AEDT Amitay Isaacs wrote:
> 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)
> 
> 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?

Yeah, this basically breaks the host so I was going to push this later today 
along with another minor fix for ecmd prior to merging the devtree stuff.

- Alistair

> Amitay.
> 






More information about the Pdbg mailing list