From 6d7ef673de06cb7bfa5820848194e6eaad2fa8d4 Mon Sep 17 00:00:00 2001
From: Peter Jones <pjones@redhat.com>
Date: Wed, 10 Sep 2014 15:47:57 -0400
Subject: [PATCH 07/18] Fix an error path not checking the return right in
make_linux_load_option
Covscan once again.
Signed-off-by: Peter Jones <pjones@redhat.com>
---
src/lib/efi.c | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
diff --git a/src/lib/efi.c b/src/lib/efi.c
index 7dc3c92..a131abe 100644
--- a/src/lib/efi.c
+++ b/src/lib/efi.c
@@ -722,7 +722,7 @@ make_linux_load_option(uint8_t **data, size_t *data_size)
size_t load_option_size = sizeof (*load_option);
efi_char16_t description[64];
uint8_t *buf;
- size_t needed;
+ ssize_t needed;
off_t buf_offset = 0, desc_offset;
load_option = calloc(1, sizeof (*load_option));
@@ -754,11 +754,19 @@ make_linux_load_option(uint8_t **data, size_t *data_size)
if (opts.iface) {
needed = make_net_load_option(opts.iface, NULL, 0);
+ if (needed < 0) {
+ free(buf);
+ return needed;
+ }
buf = extend(load_option, load_option_size, needed);
make_net_load_option(opts.iface, buf + buf_offset, needed);
buf_offset += needed;
} else {
needed = make_disk_load_option(opts.iface, NULL, 0);
+ if (needed < 0) {
+ free(buf);
+ return needed;
+ }
buf = extend(load_option, load_option_size, needed);
make_disk_load_option(opts.iface, buf + buf_offset, needed);
buf_offset += needed;
--
1.9.3