diff options
author | markj <markj@FreeBSD.org> | 2015-03-11 00:01:39 +0000 |
---|---|---|
committer | markj <markj@FreeBSD.org> | 2015-03-11 00:01:39 +0000 |
commit | 1c0a61aa611e9785df22a94fbea4a52ba293d962 (patch) | |
tree | 0c0e85ef123c492fa524f9f386b0110c83929569 /cddl | |
parent | a76e348a4b790b714d72dd53286a81bbef9b5f28 (diff) | |
download | FreeBSD-src-1c0a61aa611e9785df22a94fbea4a52ba293d962.zip FreeBSD-src-1c0a61aa611e9785df22a94fbea4a52ba293d962.tar.gz |
When copying a type from a source CTF container to a destination container,
ctf_add_type() first performs a by-name lookup of the type in the
destination container. If this lookup returns a forward declaration for an
enum, struct, or union, reset dst_type back to CTF_ERR, indicating that the
source type is not in fact present in the destination container. This
ensures that ctf_add_type() will also search the destination container's
dynamic type list for the source type.
Without this change, a pair of mutually recursive struct definitions could
cause infinite recursion in ctf_add_type() if the destination container
only contained forward declarations for the struct types: ctf_add_type()
recursively calls itself on each struct member's type, and the forward
declarations meant that the dynamic type list search would be skipped.
MFC after: 2 weeks
Sponsored by: EMC / Isilon Storage Division
Diffstat (limited to 'cddl')
-rw-r--r-- | cddl/contrib/opensolaris/common/ctf/ctf_create.c | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/cddl/contrib/opensolaris/common/ctf/ctf_create.c b/cddl/contrib/opensolaris/common/ctf/ctf_create.c index 679ed18..1c0988a 100644 --- a/cddl/contrib/opensolaris/common/ctf/ctf_create.c +++ b/cddl/contrib/opensolaris/common/ctf/ctf_create.c @@ -1313,10 +1313,13 @@ ctf_add_type(ctf_file_t *dst_fp, ctf_file_t *src_fp, ctf_id_t src_type) * unless dst_type is a forward declaration and src_type is a struct, * union, or enum (i.e. the definition of the previous forward decl). */ - if (dst_type != CTF_ERR && dst_kind != kind && ( - dst_kind != CTF_K_FORWARD || (kind != CTF_K_ENUM && - kind != CTF_K_STRUCT && kind != CTF_K_UNION))) - return (ctf_set_errno(dst_fp, ECTF_CONFLICT)); + if (dst_type != CTF_ERR && dst_kind != kind) { + if (dst_kind != CTF_K_FORWARD || (kind != CTF_K_ENUM && + kind != CTF_K_STRUCT && kind != CTF_K_UNION)) + return (ctf_set_errno(dst_fp, ECTF_CONFLICT)); + else + dst_type = CTF_ERR; + } /* * If the non-empty name was not found in the appropriate hash, search |