From ad13e48a07253e32e967fa7edae949fc82454bfe Mon Sep 17 00:00:00 2001 From: Tim Edwards Date: Fri, 20 Mar 2020 14:50:56 -0400 Subject: [PATCH] Corrected ext2spice for the case where a port has been given more than one name, because in that case one of the port records ends up with a null pointer to a node, and causes a crash condition. This can happen inadvertently, as when a connected node is not specifically designated a port, but is forced to be a port because of the connection. --- ext2spice/ext2hier.c | 2 +- ext2spice/ext2spice.c | 6 +++--- extflat/EFbuild.c | 2 ++ 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/ext2spice/ext2hier.c b/ext2spice/ext2hier.c index fc010154..64578469 100644 --- a/ext2spice/ext2hier.c +++ b/ext2spice/ext2hier.c @@ -1619,7 +1619,7 @@ esMakePorts(hc, cdata) nn = (EFNodeName *) HashGetValue(he); } - if (!(nn->efnn_node->efnode_flags & EF_PORT)) + if (nn->efnn_node && !(nn->efnn_node->efnode_flags & EF_PORT)) { nn->efnn_node->efnode_flags |= EF_PORT; nn->efnn_port = -1; // Will be sorted later diff --git a/ext2spice/ext2spice.c b/ext2spice/ext2spice.c index 94b2eb53..221483a6 100644 --- a/ext2spice/ext2spice.c +++ b/ext2spice/ext2spice.c @@ -1668,7 +1668,7 @@ topVisit(def, doStub) sname = (EFNodeName *) HashGetValue(he); if (sname == NULL) continue; snode = sname->efnn_node; - if (!(snode->efnode_flags & EF_PORT)) continue; + if ((!snode) || (!(snode->efnode_flags & EF_PORT))) continue; for (nodeName = sname; nodeName != NULL; nodeName = nodeName->efnn_next) { portorder = nodeName->efnn_port; @@ -1729,7 +1729,7 @@ topVisit(def, doStub) if (sname == NULL) continue; /* Should not happen */ snode = sname->efnn_node; - if (!(snode->efnode_flags & EF_PORT)) continue; + if ((!snode) || (!(snode->efnode_flags & EF_PORT))) continue; for (nodeName = sname; nodeName != NULL; nodeName = nodeName->efnn_next) { @@ -1787,7 +1787,7 @@ topVisit(def, doStub) if (sname == NULL) continue; snode = sname->efnn_node; - if (snode->efnode_flags & EF_SUBS_PORT) + if (snode && (snode->efnode_flags & EF_SUBS_PORT)) { if (snode->efnode_name->efnn_port < 0) { diff --git a/extflat/EFbuild.c b/extflat/EFbuild.c index f4ba250b..33e43bc6 100644 --- a/extflat/EFbuild.c +++ b/extflat/EFbuild.c @@ -466,6 +466,8 @@ efBuildEquiv(def, nodeName1, nodeName2) if (efWarn) efReadError("Merged nodes %s and %s\n", nodeName1, nodeName2); efNodeMerge(&nn1->efnn_node, &nn2->efnn_node); + if (nn1->efnn_port > 0) nn2->efnn_port = nn1->efnn_port; + else if (nn2->efnn_port > 0) nn1->efnn_port = nn2->efnn_port; } return; }