]> git.ipfire.org Git - thirdparty/lldpd.git/commitdiff
lib: remove limit on system description length
authorVincent Bernat <vincent@bernat.ch>
Tue, 14 Jul 2020 05:16:47 +0000 (07:16 +0200)
committerVincent Bernat <vincent@bernat.ch>
Tue, 14 Jul 2020 05:16:47 +0000 (07:16 +0200)
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.

src/lib/atom.c
tests/integration/test_lldpcli.py

index 39ea5f8757c98cfc4c51ab78fdbfcd8bfbc1f00c..55a1b679d543c5786a7207a6db75186333e5e588 100644 (file)
@@ -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,
index 273777a39e8d4b92314c47a9682a8886cee4a349..6a9ee801890d38ccc0fc3b2569867b48a76b89f7 100644 (file)
@@ -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):