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
This commit is contained in:
Dominique Martinet 2022-11-05 21:29:00 +09:00
parent bbedc40bf2
commit 54be500888

2
bgp.c
View file

@ -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)