summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLaurent Bercot <ska-skaware@skarnet.org>2023-01-03 13:03:31 +0000
committerLaurent Bercot <ska@appnovation.com>2023-01-03 13:03:31 +0000
commitd2d52e2e3063ad584ffc8cf855c70d1c452ee107 (patch)
treeb4749835d09f613b6a83559cdbba4f529d1bcc03
parentc39dcd41e91806d3fec45f1110e12b7c3e52a6bf (diff)
downloads6-dns-d2d52e2e3063ad584ffc8cf855c70d1c452ee107.tar.xz
bugfix: signed length in tcp prefix
Signed-off-by: Laurent Bercot <ska@appnovation.com>
-rw-r--r--src/libs6dns/s6dns_engine.c11
1 files changed, 4 insertions, 7 deletions
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)