diff options
author | Thomas Haller <thaller@redhat.com> | 2014-06-10 15:50:09 (GMT) |
---|---|---|
committer | Thomas Haller <thaller@redhat.com> | 2014-06-10 19:45:52 (GMT) |
commit | d7a9e74f82d136d1e3fa4e174e8b7ba9595ec9a9 (patch) | |
tree | ea72d0c47b2a3d972592e796f8b31a05bb847f96 | |
parent | dae0a2316ed9f5cc16670f8a49f7737d73b31c3c (diff) | |
download | libnl-d7a9e74f82d136d1e3fa4e174e8b7ba9595ec9a9.zip libnl-d7a9e74f82d136d1e3fa4e174e8b7ba9595ec9a9.tar.gz libnl-d7a9e74f82d136d1e3fa4e174e8b7ba9595ec9a9.tar.bz2 |
route/link: fix dangling pointer after rtnl_link_get_ifalias(link, NULL)
Fixed bug that left a dangling pointer after clearing the ifalias
property. This happened when calling 'rtnl_link_get_ifalias(link, NULL)'
on a link that has already an ifalias set.
This can cause a crash and/or a double-free.
Error found by coverity.
Acked-by: Thomas Graf <tgraf@suug.ch>
Signed-off-by: Thomas Haller <thaller@redhat.com>
-rw-r--r-- | lib/route/link.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/lib/route/link.c b/lib/route/link.c index 65e42ec..3d31ffc 100644 --- a/lib/route/link.c +++ b/lib/route/link.c @@ -2102,11 +2102,13 @@ const char *rtnl_link_get_ifalias(struct rtnl_link *link) void rtnl_link_set_ifalias(struct rtnl_link *link, const char *alias) { free(link->l_ifalias); - link->ce_mask &= ~LINK_ATTR_IFALIAS; if (alias) { link->l_ifalias = strdup(alias); link->ce_mask |= LINK_ATTR_IFALIAS; + } else { + link->l_ifalias = NULL; + link->ce_mask &= ~LINK_ATTR_IFALIAS; } } |