From 3b7d6baa7415ba65e08cd6d6a80b78c48b039b7e Mon Sep 17 00:00:00 2001 From: Thomas Kolb Date: Sat, 20 Jul 2024 01:01:01 +0200 Subject: [PATCH] layer2_tx: fixed packet size --- impl/src/layer2/layer2_tx.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/impl/src/layer2/layer2_tx.c b/impl/src/layer2/layer2_tx.c index 3f9815a..8277ca1 100644 --- a/impl/src/layer2/layer2_tx.c +++ b/impl/src/layer2/layer2_tx.c @@ -62,13 +62,14 @@ result_t layer2_tx_fill_packet_queue(layer2_tx_t *ctx) // a packet is available -> move it to the queue header.tx_seq_nr = ctx->next_seq_nr; - uint8_t *packetbuf = malloc(2048); + static const size_t packetbuf_size = 2048; + uint8_t *packetbuf = malloc(packetbuf_size); if(!packetbuf) { LOG(LVL_ERR, "malloc failed."); return ERR_NO_MEM; } - ret = read(ctx->tun_fd, packetbuf, sizeof(packetbuf)); + ret = read(ctx->tun_fd, packetbuf, packetbuf_size); if(ret < 0) { LOG(LVL_ERR, "read: %s", strerror(errno)); free(packetbuf);