elf: fix memcmp() overflow 65/19265/3
authorBenoît Ganne <bganne@cisco.com>
Fri, 26 Apr 2019 09:09:49 +0000 (11:09 +0200)
committerDave Barach <openvpp@barachs.net>
Tue, 30 Apr 2019 16:54:08 +0000 (16:54 +0000)
name can be (and will be) smaller than section_name_start. Both name and
section_name_start are NULL-terminated so we can use strcmp.

Change-Id: Iec414810109f9267de20c25c0fe601df35daf89e
Signed-off-by: Benoît Ganne <bganne@cisco.com>
src/vppinfra/elf_clib.c

index 7bb72ee..2bc05e1 100644 (file)
@@ -153,7 +153,7 @@ clib_elf_parse_file (clib_elf_main_t * cem,
       clib_elf_section_bounds_t *b;
 
       /* Section name must begin with CLIB_ELF_SECTION key. */
-      if (memcmp (name, section_name_start, section_name_start_len))
+      if (strcmp ((char *) name, section_name_start))
        continue;
 
       name += section_name_start_len;