From efc08df165e7209e79d68b25017a970c4b6c0504 Mon Sep 17 00:00:00 2001 From: Peter Jones Date: Wed, 10 Sep 2014 15:47:57 -0400 Subject: [PATCH 08/31] Fix an error path not checking the return right in make_linux_load_option Covscan once again. Signed-off-by: Peter Jones --- 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; -- 2.7.4