aboutsummaryrefslogtreecommitdiff
path: root/libctf
diff options
context:
space:
mode:
authorNick Alcock <nick.alcock@oracle.com>2020-06-02 20:49:14 +0100
committerNick Alcock <nick.alcock@oracle.com>2020-07-22 17:57:32 +0100
commit96e3ec29664810995d6d7d3b6fd6ae2d19c532bd (patch)
tree6b13dd4277d8647d015f6e17b681145d9f9b2550 /libctf
parent502e838ed9657ee74cdb4f53798e1468004c9524 (diff)
downloadgdb-96e3ec29664810995d6d7d3b6fd6ae2d19c532bd.zip
gdb-96e3ec29664810995d6d7d3b6fd6ae2d19c532bd.tar.gz
gdb-96e3ec29664810995d6d7d3b6fd6ae2d19c532bd.tar.bz2
libctf, types: ints, floats and typedefs with no name are invalid
Report them as such, rather than letting ctf_decl_sprintf wrongly conclude that the printing of zero characters means we are out of memory. libctf/ * ctf-types.c (ctf_type_aname): Return ECTF_CORRUPT if ints, floats or typedefs have no name. Fix comment typo.
Diffstat (limited to 'libctf')
-rw-r--r--libctf/ChangeLog5
-rw-r--r--libctf/ctf-types.c11
2 files changed, 15 insertions, 1 deletions
diff --git a/libctf/ChangeLog b/libctf/ChangeLog
index 78f8f7e..f0e2001 100644
--- a/libctf/ChangeLog
+++ b/libctf/ChangeLog
@@ -1,5 +1,10 @@
2020-07-22 Nick Alcock <nick.alcock@oracle.com>
+ * ctf-types.c (ctf_type_aname): Return ECTF_CORRUPT if
+ ints, floats or typedefs have no name. Fix comment typo.
+
+2020-07-22 Nick Alcock <nick.alcock@oracle.com>
+
* ctf-create.c (ctf_add_slice): Support slices of any kind that
resolves to an integral type.
* ctf-types.c (ctf_type_encoding): Resolve the type before
diff --git a/libctf/ctf-types.c b/libctf/ctf-types.c
index f5a1fc0..db42b9e 100644
--- a/libctf/ctf-types.c
+++ b/libctf/ctf-types.c
@@ -316,7 +316,7 @@ ctf_id_t ctf_lookup_by_rawhash (ctf_file_t *fp, ctf_names_t *np, const char *nam
return id;
}
-/* Lookup the given type ID and return its name as a new dynamcally-allocated
+/* Lookup the given type ID and return its name as a new dynamically-allocated
string. */
char *
@@ -379,6 +379,15 @@ ctf_type_aname (ctf_file_t *fp, ctf_id_t type)
case CTF_K_INTEGER:
case CTF_K_FLOAT:
case CTF_K_TYPEDEF:
+ /* Integers, floats, and typedefs must always be named types. */
+
+ if (name[0] == '\0')
+ {
+ ctf_set_errno (fp, ECTF_CORRUPT);
+ ctf_decl_fini (&cd);
+ return NULL;
+ }
+
ctf_decl_sprintf (&cd, "%s", name);
break;
case CTF_K_POINTER: