From 54be5008888bb26659416dec86a6b0cb3990aa9a Mon Sep 17 00:00:00 2001 From: Dominique Martinet Date: Sat, 5 Nov 2022 21:29:00 +0900 Subject: [PATCH] bgp_write: fix sent data (offset) on partial write &peer->outbuf->packet has a non-1 size, so &foo + offset would incorrectly offset by sizeof(packet) * offset, while it is meant as a byte offset. Cast to char * to have a simple offset. Reported-by: Coverity#375309 --- bgp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bgp.c b/bgp.c index 2791ca3..181de9a 100644 --- a/bgp.c +++ b/bgp.c @@ -1028,7 +1028,7 @@ static int bgp_write(struct bgp_peer *peer) int len = htons(peer->outbuf->packet.header.len); int r; - while ((r = write(peer->sock, &peer->outbuf->packet + peer->outbuf->done, + while ((r = write(peer->sock, (char*)&peer->outbuf->packet + peer->outbuf->done, len - peer->outbuf->done)) == -1) { if (errno == EINTR)