summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Mustacchi <rm@fingolfin.org>2020-06-05 15:34:02 -0700
committerRobert Mustacchi <rm@fingolfin.org>2020-06-11 09:56:18 -0700
commit7fa359c09493c7b56e7c3e98fccc7e5cc0f09b48 (patch)
treec4c71e39e8f37b69a63e1380750a44904493e4a2
parent6cdd461fe55315d9bc0ba40ea7da22cddbdcf784 (diff)
downloadillumos-joyent-7fa359c09493c7b56e7c3e98fccc7e5cc0f09b48.tar.gz
12820 failure in dladm_ether_info() can lead to a double free
Reviewed by: Andy Fiddaman <omnios@citrus-it.co.uk> Reviewed by: Igor Kozhukhov <igor@dilos.org> Reviewed by: Toomas Soome <toomas@me.com> Approved by: Dan McDonald <danmcd@joyent.com>
-rw-r--r--usr/src/cmd/dladm/dladm.c6
-rw-r--r--usr/src/lib/libdladm/common/libdlether.c4
2 files changed, 6 insertions, 4 deletions
diff --git a/usr/src/cmd/dladm/dladm.c b/usr/src/cmd/dladm/dladm.c
index adb04d1d12..969bcaddba 100644
--- a/usr/src/cmd/dladm/dladm.c
+++ b/usr/src/cmd/dladm/dladm.c
@@ -7676,8 +7676,9 @@ show_etherprop(dladm_handle_t dh, datalink_id_t linkid, void *arg)
}
status = dladm_ether_info(dh, linkid, &eattr);
- if (status != DLADM_STATUS_OK)
- goto cleanup;
+ if (status != DLADM_STATUS_OK) {
+ return (DLADM_WALK_CONTINUE);
+ }
(void) strlcpy(ebuf.eth_ptype, "current", sizeof (ebuf.eth_ptype));
@@ -7699,7 +7700,6 @@ show_etherprop(dladm_handle_t dh, datalink_id_t linkid, void *arg)
if (statep->es_extended)
show_ether_xprop(arg, &eattr);
-cleanup:
dladm_ether_info_done(&eattr);
return (DLADM_WALK_CONTINUE);
}
diff --git a/usr/src/lib/libdladm/common/libdlether.c b/usr/src/lib/libdladm/common/libdlether.c
index 4e3a7ead4c..2914174f62 100644
--- a/usr/src/lib/libdladm/common/libdlether.c
+++ b/usr/src/lib/libdladm/common/libdlether.c
@@ -375,6 +375,8 @@ dladm_ether_info_done(dladm_ether_info_t *eattr)
{
int i;
- for (i = CURRENT; i <= PEERADV; i++)
+ for (i = CURRENT; i <= PEERADV; i++) {
free(eattr->lei_attr[i].le_spdx);
+ eattr->lei_attr[i].le_spdx = NULL;
+ }
}