From e19e50f6a99a0e5d295eba91309e5573b744be56 Mon Sep 17 00:00:00 2001 From: Vincent Bernat Date: Sun, 18 Sep 2022 10:03:43 +0200 Subject: [PATCH] lib: zero receive buffer 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 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib/connection.c b/src/lib/connection.c index 2eed5a4b..e1acce0f 100644 --- a/src/lib/connection.c +++ b/src/lib/connection.c @@ -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) { -- 2.39.5