From: Vincent Bernat Date: Tue, 14 Jul 2020 05:16:47 +0000 (+0200) Subject: lib: remove limit on system description length X-Git-Tag: 1.0.6~4 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=78243478dcec865486b387cf361783dc137015b5;p=thirdparty%2Flldpd.git lib: remove limit on system description length The limit was introduced in 9c49cedf8e75 while fixing a memory leak. The state data is used to ensure we don't interleave operations. We need to handle the case where the value is truncated because it is larger than the allocated size. Fix #408. --- diff --git a/src/lib/atom.c b/src/lib/atom.c index 39ea5f87..55a1b679 100644 --- a/src/lib/atom.c +++ b/src/lib/atom.c @@ -331,7 +331,7 @@ _lldpctl_do_something(lldpctl_conn_t *conn, conn->state_data[0] = 0; } if (conn->state == state_send && - (state_data == NULL || !strncmp(conn->state_data, state_data, sizeof(conn->state_data)))) { + (state_data == NULL || !strncmp(conn->state_data, state_data, sizeof(conn->state_data) - 1))) { /* We need to send the currently built message */ rc = lldpctl_send(conn); if (rc < 0) @@ -339,7 +339,7 @@ _lldpctl_do_something(lldpctl_conn_t *conn, conn->state = state_recv; } if (conn->state == state_recv && - (state_data == NULL || !strncmp(conn->state_data, state_data, sizeof(conn->state_data)))) { + (state_data == NULL || !strncmp(conn->state_data, state_data, sizeof(conn->state_data) - 1))) { /* We need to receive the answer */ while ((rc = ctl_msg_recv_unserialized(&conn->input_buffer, &conn->input_buffer_len, diff --git a/tests/integration/test_lldpcli.py b/tests/integration/test_lldpcli.py index 273777a3..6a9ee801 100644 --- a/tests/integration/test_lldpcli.py +++ b/tests/integration/test_lldpcli.py @@ -588,6 +588,12 @@ def test_return_code(lldpd1, lldpcli, namespaces): ("configure system interface promiscuous", "iface-promisc", "yes"), ("configure system bond-slave-src-mac-type fixed", "bond-slave-src-mac-type", "fixed"), + ("configure system description " + "1234567890123456789012345678901234567890" + "1234567890123456789012345678901234567890", + "description", + "1234567890123456789012345678901234567890" + "1234567890123456789012345678901234567890"), ("configure lldp agent-type nearest-customer-bridge", "lldp-agent-type", "nearest customer bridge")]) def test_config_change(lldpd1, lldpcli, namespaces, command, name, expected):