[PATCH] lib/pb-protocol: Fix NULL dereference on non-powerpc

Cyril Bur cyril.bur at au1.ibm.com
Tue Dec 22 09:12:06 AEDT 2015


On Mon, 21 Dec 2015 16:29:57 +1100
Samuel Mendoza-Jonas <sam.mj at au1.ibm.com> wrote:

> If not running on a powerpc platform the bmc_mac pointer remains NULL.
> If this is the case set an address of zero when serialising rather
> than dereferencing the pointer.
> 
> Signed-off-by: Samuel Mendoza-Jonas <sam.mj at au1.ibm.com>
Reviewed-by: Cyril Bur <cyril.bur at au1.ibm.com>
> ---
>  lib/pb-protocol/pb-protocol.c | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/lib/pb-protocol/pb-protocol.c b/lib/pb-protocol/pb-protocol.c
> index 9d07a58..42506e2 100644
> --- a/lib/pb-protocol/pb-protocol.c
> +++ b/lib/pb-protocol/pb-protocol.c
> @@ -424,7 +424,10 @@ int pb_protocol_serialise_system_info(const struct system_info *sysinfo,
>  		pos += pb_protocol_serialise_string(pos, bd_info->mountpoint);
>  	}
>  
> -	memcpy(pos, sysinfo->bmc_mac, HWADDR_SIZE);
> +	if (sysinfo->bmc_mac)
> +		memcpy(pos, sysinfo->bmc_mac, HWADDR_SIZE);
> +	else
> +		memset(pos, 0, HWADDR_SIZE);
>  	pos += HWADDR_SIZE;
>  
>  	assert(pos <= buf + buf_len);



More information about the Petitboot mailing list