This is all in the effort to convince coverity that it doesn't
dereference buf when size==0, which it already doesn't.
Signed-off-by: Peter Jones <pjones@redhat.com>
ssize_t len = utf8len(lf, -1) + 1;
ssize_t req = sizeof (*file) + len * sizeof (uint16_t);
+ if (len == 0) {
+ errno = EINVAL;
+ efi_error("%s() called with %s file path", __func__,
+ filepath == NULL ? "NULL" : "empty");
+ return -1;
+ }
sz = efidp_make_generic(buf, size, EFIDP_MEDIA_TYPE, EFIDP_MEDIA_FILE,
req);
if (size && sz == req) {
if (!size)
return total_size;
+
+ if (!buf) {
+ errno = EINVAL;
+ efi_error("%s was called with nonzero size and NULL buffer",
+ __func__);
+ return -1;
+ }
+
if (size < total_size) {
- efi_error("total size is bigger than size limit");
errno = ENOSPC;
+ efi_error("total size is bigger than size limit");
return -1;
}