_CTF_ITEM (ECTF_NEXT_WRONGFP, "Iteration entity changed in mid-iterate.") \
_CTF_ITEM (ECTF_FLAGS, "CTF header contains flags unknown to libctf.") \
_CTF_ITEM (ECTF_NEEDSBFD, "This feature needs a libctf with BFD support.") \
- _CTF_ITEM (ECTF_INCOMPLETE, "Type is not a complete type.")
+ _CTF_ITEM (ECTF_INCOMPLETE, "Type is not a complete type.") \
+ _CTF_ITEM (ECTF_NONAME, "Type name must not be empty.")
#define ECTF_BASE 1000 /* Base value for libctf errnos. */
#undef _CTF_FIRST
};
-#define ECTF_NERR (ECTF_INCOMPLETE - ECTF_BASE + 1) /* Count of CTF errors. */
+#define ECTF_NERR (ECTF_NONAME - ECTF_BASE + 1) /* Count of CTF errors. */
/* The CTF data model is inferred to be the caller's data model or the data
model of the given object, unless ctf_setmodel is explicitly called. */
+2021-01-27 Nick Alcock <nick.alcock@oracle.com>
+
+ * ctf-create.c (ctf_add_encoded): Add check for non-empty name.
+ (ctf_add_forward): Likewise.
+ (ctf_add_typedef): Likewise.
+
2021-01-27 Nick Alcock <nick.alcock@oracle.com>
* ctf-open.c (init_types): Rip out code to check anonymous typedef
if (ep == NULL)
return (ctf_set_errno (fp, EINVAL));
+ if (name == NULL || name[0] == '\0')
+ return (ctf_set_errno (fp, ECTF_NONAME));
+
if ((type = ctf_add_generic (fp, flag, name, kind, &dtd)) == CTF_ERR)
return CTF_ERR; /* errno is set for us. */
if (!ctf_forwardable_kind (kind))
return (ctf_set_errno (fp, ECTF_NOTSUE));
+ if (name == NULL || name[0] == '\0')
+ return (ctf_set_errno (fp, ECTF_NONAME));
+
/* If the type is already defined or exists as a forward tag, just
return the ctf_id_t of the existing definition. */
- if (name != NULL)
- type = ctf_lookup_by_rawname (fp, kind, name);
+ type = ctf_lookup_by_rawname (fp, kind, name);
if (type)
return type;
if (ref == CTF_ERR || ref > CTF_MAX_TYPE)
return (ctf_set_errno (fp, EINVAL));
+ if (name == NULL || name[0] == '\0')
+ return (ctf_set_errno (fp, ECTF_NONAME));
+
if (ref != 0 && ctf_lookup_by_id (&tmp, ref) == NULL)
return CTF_ERR; /* errno is set for us. */