aboutsummaryrefslogtreecommitdiff
path: root/libctf/ctf-open.c
diff options
context:
space:
mode:
authorNick Alcock <nick.alcock@oracle.com>2020-06-03 17:31:44 +0100
committerNick Alcock <nick.alcock@oracle.com>2020-07-22 17:57:54 +0100
commitec388c16cd4217a64907e4e133d2102cc4fe608a (patch)
treeb2843ad6885d24e75b5351487b008fe2598fa3d0 /libctf/ctf-open.c
parent67d4cc671b7b3c49f748546a510005333fcbc465 (diff)
downloadgdb-ec388c16cd4217a64907e4e133d2102cc4fe608a.zip
gdb-ec388c16cd4217a64907e4e133d2102cc4fe608a.tar.gz
gdb-ec388c16cd4217a64907e4e133d2102cc4fe608a.tar.bz2
libctf: error out on corrupt CTF with invalid header flags
If corrupt CTF with invalid header flags is passed in, return the new error ECTF_FLAGS. include/ * ctf-api.h (ECTF_FLAGS): New. (ECTF_NERR): Adjust. * ctf.h (CTF_F_MAX): New. libctf/ * ctf-open.c (ctf_bufopen_internal): Diagnose invalid flags.
Diffstat (limited to 'libctf/ctf-open.c')
-rw-r--r--libctf/ctf-open.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/libctf/ctf-open.c b/libctf/ctf-open.c
index b7846bd..f8eeaab 100644
--- a/libctf/ctf-open.c
+++ b/libctf/ctf-open.c
@@ -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));