OSDN Git Service

efi_loadopt_create(): check buf for NULLness.
authorPeter Jones <pjones@redhat.com>
Mon, 1 May 2017 19:04:24 +0000 (15:04 -0400)
committerPeter Jones <pjones@redhat.com>
Mon, 1 May 2017 20:06:30 +0000 (16:06 -0400)
Found by covscan.

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

index d4c2d46..8db8074 100644 (file)
@@ -46,13 +46,20 @@ efi_loadopt_create(uint8_t *buf, ssize_t size, uint32_t attributes,
        ssize_t sz = sizeof (attributes)
                     + sizeof (uint16_t) + desc_len
                     + dp_size + optional_data_size;
+
        if (size == 0)
                return sz;
+
        if (size < sz) {
                errno = ENOSPC;
                return -1;
        }
 
+       if (!buf) {
+               errno = EINVAL;
+               return -1;
+       }
+
        if (!optional_data && optional_data_size != 0) {
                errno = EINVAL;
                return -1;