return NULL;
case lldpctl_k_med_location_country:
if (m->location->format != LLDP_MED_LOCFORMAT_CIVIC) break;
+ if (m->location->data_len < 4) return NULL;
value = _lldpctl_alloc_in_atom(atom, 3);
if (!value) return NULL;
memcpy(value, m->location->data + 2, 2);
{
struct _lldpctl_atom_med_caelements_list_t *plist =
(struct _lldpctl_atom_med_caelements_list_t *)atom;
- struct ca_iter *iter = _lldpctl_alloc_in_atom(atom, sizeof(struct ca_iter));
- if (!iter) return NULL;
+ struct ca_iter *iter;
+ if (plist->parent->location->data_len < 4 ||
+ *(uint8_t*)plist->parent->location->data < 3 ||
+ !(iter = _lldpctl_alloc_in_atom(atom, sizeof(struct ca_iter))))
+ return NULL;
iter->data = (uint8_t*)plist->parent->location->data + 4;
iter->data_len = *(uint8_t*)plist->parent->location->data - 3;
return (lldpctl_atom_iter_t*)iter;
'is not electrically isolated'),
'lldp.eth0.port.power.max-power': '51000'
}
+
+@pytest.mark.skipif("'LLDP-MED' not in config.lldpd.features",
+ readon="LLDP-MED not supported")
+def test_med_loc_malformed(lldpd1, lldpcli, namespaces):
+ with namespaces(2):
+ pytest.helpers.send_pcap('data/med-loc-malformed.pcap', 'eth1')
+ with namespaces(1):
+ out = lldpcli("-f", "keyvalue", "show", "neighbors", "details")
+ for k in list(out.keys()):
+ if not k.startswith("lldp.eth0.lldp-med."):
+ del out[k]
+ assert out == {
+ 'lldp.eth0.lldp-med.device-type': 'Communication Device Endpoint (Class III)',
+ 'lldp.eth0.lldp-med.Capabilities.available': 'yes',
+ 'lldp.eth0.lldp-med.Policy.available': 'yes',
+ 'lldp.eth0.lldp-med.Location.available': 'yes',
+ 'lldp.eth0.lldp-med.Inventory.available': 'yes',
+ 'lldp.eth0.lldp-med.policy.apptype': 'Voice',
+ 'lldp.eth0.lldp-med.policy.defined': 'yes',
+ 'lldp.eth0.lldp-med.policy.priority': 'Best effort',
+ 'lldp.eth0.lldp-med.policy.pcp': '0',
+ 'lldp.eth0.lldp-med.policy.dscp': '0',
+ 'lldp.eth0.lldp-med.Civic address.country': 'F5'
+ # Truncated
+ }