]> git.ipfire.org Git - thirdparty/lldpd.git/commitdiff
lib: zero receive buffer
authorVincent Bernat <vincent@bernat.ch>
Sun, 18 Sep 2022 08:03:43 +0000 (10:03 +0200)
committerVincent Bernat <vincent@bernat.ch>
Sun, 18 Sep 2022 08:03:43 +0000 (10:03 +0200)
This is not strictly needed as we only use the part that was correctly
written by recv(), but it helps static tool analysis.

src/lib/connection.c

index 2eed5a4b31544b4e7c2779ffcaab606e698b7fcb..e1acce0f5e8f4ee37faccdc93d09dab78e5e5905 100644 (file)
@@ -160,7 +160,7 @@ _lldpctl_needs(lldpctl_conn_t *conn, size_t length)
        uint8_t *buffer;
        ssize_t  rc;
 
-       if ((buffer = malloc(length)) == NULL)
+       if ((buffer = calloc(1, length)) == NULL)
                return SET_ERROR(conn, LLDPCTL_ERR_NOMEM);
        rc = conn->recv(conn, buffer, length, conn->user_data);
        if (rc < 0) {