]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blobdiff - libctf/ctf-open.c
libctf: error out on corrupt CTF with invalid header flags
[thirdparty/binutils-gdb.git] / libctf / ctf-open.c
index b7846bd001473bd9889ee2a293fecd36be64e578..f8eeaab0168bd4df0cc10d22b1b1c9ecbfabf5c5 100644 (file)
@@ -1384,6 +1384,9 @@ ctf_bufopen_internal (const ctf_sect_t *ctfsect, const ctf_sect_t *symsect,
   if (pp->ctp_version < CTF_VERSION_3)
     hdrsz = sizeof (ctf_header_v2_t);
 
+  if (_libctf_unlikely_ (pp->ctp_flags > CTF_F_MAX))
+    return (ctf_set_open_errno (errp, ECTF_FLAGS));
+
   if (ctfsect->cts_size < hdrsz)
     return (ctf_set_open_errno (errp, ECTF_NOCTFBUF));