OSDN Git Service

Test a couple of pointers for NULL-ness.
authorPeter Jones <pjones@redhat.com>
Mon, 12 Jan 2015 19:09:23 +0000 (14:09 -0500)
committerPeter Jones <pjones@redhat.com>
Mon, 12 Jan 2015 19:13:58 +0000 (14:13 -0500)
In both of these cases buf is NULL if and only if the size is also 0,
and thus we'll fail the test anyway, but coverify isn't noticing that.
And I'm tired of talking to a piece of software about its deficiencies.

Signed-off-by: Peter Jones <pjones@redhat.com>
src/lib/efi.c

index d8dc101..6350c6f 100644 (file)
@@ -189,7 +189,7 @@ make_edd10_device_path(uint32_t hardware_device, uint8_t *buf, size_t size)
        hw->length = EDD10_HARDWARE_VENDOR_PATH_LENGTH;
        memcpy(&(hw->vendor_guid), &guid, sizeof(guid));
        *data = hardware_device;
-       if (size >= hw->length)
+       if (size >= hw->length && buf != NULL)
                memcpy(buf, buffer, hw->length);
        return hw->length;
 }
@@ -399,7 +399,7 @@ make_harddrive_device_path(uint32_t num, uint64_t part_start,
        if (signature) memcpy(p.signature, signature, 16);
        p.mbr_type = mbr_type;
        p.signature_type = signature_type;
-       if (size >= p.length)
+       if (size >= p.length && buf != NULL)
                memcpy(buf, &p, p.length);
        return p.length;
 }