libctf: unidentified type kinds on open are a sign of file corruption
authorNick Alcock <nick.alcock@oracle.com>
Wed, 19 Jun 2019 11:27:18 +0000 (12:27 +0100)
committerNick Alcock <nick.alcock@oracle.com>
Fri, 21 Jun 2019 12:04:02 +0000 (13:04 +0100)
If we see a CTF type with a kind we do not recognize in its ctt_info
during opening, we cannot skip it and continue opening the file: if the
type kind is unknown, we do not know how long its vlen is, and we cannot
have skipped past it: so if we continue reading we will almost certainly
read in part of the vlen as if it were a new ctf_type_t.

Avoid this trouble by considering unknown type kinds to be a reason to
return ECTF_CORRUPT, just like everything else that reads in type kinds
does.

libctf/
* ctf-open.c (ctf_types): Fail when unidentified type kinds are
seen.

libctf/ChangeLog
libctf/ctf-open.c

index 9ff7cd4146bb3e58e9592eeb00a129475710e78f..ad5685b69147767dac01875e17da755e22effcfc 100644 (file)
@@ -1,3 +1,8 @@
+2019-06-19  Nick Alcock <nick.alcock@oracle.com>
+
+       * ctf-open.c (ctf_types): Fail when unidentified type kinds are
+       seen.
+
 2019-06-19  Nick Alcock <nick.alcock@oracle.com>
 
        * ctf-open.c (ctf_bufopen): Dump header offsets into the debugging
index df735acb4085ce6bf14828b9bbcbf6ec50a9ce44..14f7062590abe48f02ed7fb2ec831259d8a77e30 100644 (file)
@@ -856,6 +856,10 @@ init_types (ctf_file_t *fp, ctf_header_t *cth)
          if (err != 0 && err != ECTF_STRTAB)
            return err;
          break;
+       default:
+         ctf_dprintf ("unhandled CTF kind in endianness conversion -- %x\n",
+                      kind);
+         return ECTF_CORRUPT;
        }
 
       *xp = (uint32_t) ((uintptr_t) tp - (uintptr_t) fp->ctf_buf);
This page took 0.025253 seconds and 4 git commands to generate.