From 96fbe51956c9df8bdb8317413b1c487b14e4ee68 Mon Sep 17 00:00:00 2001 From: "Jonathan T. Looney" Date: Fri, 20 Nov 2020 17:26:02 +0000 Subject: When copying types from one CTF container to another, ensure that we encode 0-length (i.e. "") structure and union member names as offset 0. This ensures that we don't confuse other parts of the CTF code which expect this encoding. This resolves a Dtrace error resolving members of anonymous structs/unions within the (struct mbuf) type which some users were seeing after r366908. While here, update the code in ctf_add_generic() to encode 0-length type names as offset 0. Reviewed by: markj MFC after: 2 weeks Sponsored by: Netflix Differential Revision: https://reviews.freebsd.org/D27246 --- cddl/contrib/opensolaris/common/ctf/ctf_create.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'cddl/contrib') diff --git a/cddl/contrib/opensolaris/common/ctf/ctf_create.c b/cddl/contrib/opensolaris/common/ctf/ctf_create.c index 46e2b7faf437..ae4cc7f31176 100644 --- a/cddl/contrib/opensolaris/common/ctf/ctf_create.c +++ b/cddl/contrib/opensolaris/common/ctf/ctf_create.c @@ -615,7 +615,7 @@ ctf_add_generic(ctf_file_t *fp, uint_t flag, const char *name, ctf_dtdef_t **rp) if ((dtd = ctf_alloc(sizeof (ctf_dtdef_t))) == NULL) return (ctf_set_errno(fp, EAGAIN)); - if (name != NULL && (s = ctf_strdup(name)) == NULL) { + if (name != NULL && *name != '\0' && (s = ctf_strdup(name)) == NULL) { ctf_free(dtd, sizeof (ctf_dtdef_t)); return (ctf_set_errno(fp, EAGAIN)); } @@ -1217,7 +1217,7 @@ membadd(const char *name, ctf_id_t type, ulong_t offset, void *arg) if ((dmd = ctf_alloc(sizeof (ctf_dmdef_t))) == NULL) return (ctf_set_errno(ctb->ctb_file, EAGAIN)); - if (name != NULL && (s = ctf_strdup(name)) == NULL) { + if (name != NULL && *name != '\0' && (s = ctf_strdup(name)) == NULL) { ctf_free(dmd, sizeof (ctf_dmdef_t)); return (ctf_set_errno(ctb->ctb_file, EAGAIN)); } -- cgit v1.2.3