From: Vincent Bernat Date: Sat, 22 Aug 2015 14:39:13 +0000 (+0200) Subject: lib/atom: only allow custom TLV modification for local ports X-Git-Tag: 0.8.0~83 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=4e15b7d1cc9a5a5208c87b6341649d889f21d9d1;p=thirdparty%2Flldpd.git lib/atom: only allow custom TLV modification for local ports --- diff --git a/src/lib/atoms/custom.c b/src/lib/atoms/custom.c index 9d6cdb7e..a888d988 100644 --- a/src/lib/atoms/custom.c +++ b/src/lib/atoms/custom.c @@ -107,6 +107,12 @@ _lldpctl_atom_set_int_custom(lldpctl_atom_t *atom, lldpctl_key_t key, struct _lldpctl_atom_custom_t *custom = (struct _lldpctl_atom_custom_t *)atom; + /* Only local port can be modified */ + if (!custom->parent->local) { + SET_ERROR(atom->conn, LLDPCTL_ERR_NOT_EXIST); + return NULL; + } + switch (key) { case lldpctl_k_custom_tlv_oui_subtype: if (value < 0 || value > 255) goto bad; @@ -147,6 +153,12 @@ _lldpctl_atom_set_buffer_custom(lldpctl_atom_t *atom, lldpctl_key_t key, struct _lldpctl_atom_custom_t *custom = (struct _lldpctl_atom_custom_t *)atom; + /* Only local port can be modified */ + if (!custom->parent->local) { + SET_ERROR(atom->conn, LLDPCTL_ERR_NOT_EXIST); + return NULL; + } + switch (key) { case lldpctl_k_custom_tlv_oui: memcpy(&custom->tlv->oui, buf, min(n, sizeof(custom->tlv->oui)));