]> git.ozlabs.org Git - petitboot/commitdiff
lib/pb-protocol: Fix NULL dereference on non-powerpc
authorSamuel Mendoza-Jonas <sam.mj@au1.ibm.com>
Mon, 21 Dec 2015 05:16:40 +0000 (16:16 +1100)
committerSamuel Mendoza-Jonas <sam.mj@au1.ibm.com>
Mon, 21 Dec 2015 05:16:40 +0000 (16:16 +1100)
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@au1.ibm.com>
lib/pb-protocol/pb-protocol.c

index 9d07a588f92a5a6c3792b67a27ee507fdf2e4d4d..42506e218fad289e51c934f6ad5d5643b5004918 100644 (file)
@@ -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);