aboutsummaryrefslogtreecommitdiffstats
path: root/vppinfra/vppinfra/elf.c
diff options
context:
space:
mode:
authorDave Barach <dave@barachs.net>2016-08-05 10:10:18 -0400
committerDave Barach <dave@barachs.net>2016-08-05 10:10:38 -0400
commitf9c231ec12c2233557bfbb58feb87a1fcddf224a (patch)
tree6ee8846be9a6c79d68d0364c00cc58b2f3547ddd /vppinfra/vppinfra/elf.c
parent56faee837281c7f9c28aa40dbf0f6e4620b76be8 (diff)
vpp-189 Clean up more coverity warnings
Time to make the donuts Change-Id: I528937800f7daefce19723dda0216e58d857942c Signed-off-by: Dave Barach <dave@barachs.net>
Diffstat (limited to 'vppinfra/vppinfra/elf.c')
-rw-r--r--vppinfra/vppinfra/elf.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/vppinfra/vppinfra/elf.c b/vppinfra/vppinfra/elf.c
index 7fe3048b4c7..71ae1d33d70 100644
--- a/vppinfra/vppinfra/elf.c
+++ b/vppinfra/vppinfra/elf.c
@@ -559,7 +559,8 @@ format_elf_main (u8 * s, va_list * args)
s = format (s, "\nSections %d at file offset 0x%Lx-0x%Lx:\n",
fh->section_header_count,
fh->section_header_file_offset,
- fh->section_header_file_offset + fh->section_header_count * fh->section_header_size);
+ fh->section_header_file_offset +
+ (u64) fh->section_header_count * fh->section_header_size);
s = format (s, "%U\n", format_elf_section, em, 0);
vec_foreach (h, copy)
s = format (s, "%U\n", format_elf_section, em, h);
@@ -1604,7 +1605,7 @@ static void layout_sections (elf_main_t * em)
fh->section_header_file_offset = file_offset;
fh->section_header_count = vec_len (em->sections) - n_deleted_sections;
- file_offset += fh->section_header_count * fh->section_header_size;
+ file_offset += (u64) fh->section_header_count * fh->section_header_size;
}
{
@@ -1809,7 +1810,11 @@ clib_error_t * elf_write_file (elf_main_t * em, char * file_name)
continue;
if (fseek (f, s->header.file_offset, SEEK_SET) < 0)
- return clib_error_return_unix (0, "fseek 0x%Lx", s->header.file_offset);
+ {
+ fclose(f);
+ return clib_error_return_unix (0, "fseek 0x%Lx",
+ s->header.file_offset);
+ }
if (s->header.type == ELF_SECTION_NO_BITS)
/* don't write for .bss sections */;