]> git.ipfire.org Git - thirdparty/lldpd.git/commitdiff
lib/atom: only allow custom TLV modification for local ports
authorVincent Bernat <vincent@bernat.im>
Sat, 22 Aug 2015 14:39:13 +0000 (16:39 +0200)
committerVincent Bernat <vincent@bernat.im>
Sat, 22 Aug 2015 14:39:13 +0000 (16:39 +0200)
src/lib/atoms/custom.c

index 9d6cdb7e0051b83cc00014f4e2910f235c27d4e6..a888d98871e0ecff24584690302f328be32d0018 100644 (file)
@@ -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)));