From d2d52e2e3063ad584ffc8cf855c70d1c452ee107 Mon Sep 17 00:00:00 2001 From: Laurent Bercot Date: Tue, 3 Jan 2023 13:03:31 +0000 Subject: bugfix: signed length in tcp prefix Signed-off-by: Laurent Bercot --- src/libs6dns/s6dns_engine.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) (limited to 'src/libs6dns') diff --git a/src/libs6dns/s6dns_engine.c b/src/libs6dns/s6dns_engine.c index 4d61e78..75b41cc 100644 --- a/src/libs6dns/s6dns_engine.c +++ b/src/libs6dns/s6dns_engine.c @@ -56,8 +56,8 @@ static int s6dns_mininetstring_read (int fd, stralloc *sa, uint32_t *w) { if (!*w) { - char pack[2] ; - switch (fd_read(fd, pack, 2)) + unsigned char pack[2] ; + switch (fd_read(fd, (char *)pack, 2)) { case -1 : return -1 ; case 0 : return 0 ; @@ -83,9 +83,7 @@ static int s6dns_mininetstring_read (int fd, stralloc *sa, uint32_t *w) *w &= ~(1U << 30) ; } { - size_t r ; - errno = EPIPE ; - r = allread(fd, sa->s + sa->len, *w) ; + size_t r = allread(fd, sa->s + sa->len, *w) ; sa->len += r ; *w -= r ; } return *w ? -1 : 1 ; @@ -218,8 +216,7 @@ static int s6dns_engine_write_udp (s6dns_engine_t *dt, tain const *stamp) static int s6dns_engine_write_tcp (s6dns_engine_t *dt, tain const *stamp) { - size_t r ; - r = allwrite(dt->fd, dt->sa.s + dt->protostate, dt->querylen - dt->protostate) ; + size_t r = allwrite(dt->fd, dt->sa.s + dt->protostate, dt->querylen - dt->protostate) ; dt->protostate += r ; if (r) dt->flagconnecting = 0 ; if (dt->protostate < dt->sa.len) -- cgit v1.2.3