From 7e3c303ad0ce2d1f4a2fc83d8db495e9c2e16173 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Josef=20S=C3=B6ntgen?= Date: Wed, 6 Jun 2012 16:37:47 +0200 Subject: [PATCH] Fix bugs in libc_noux's sendto() method The sysio's struct fields need to be properly set on each syscall. This fixes a bug where the wrong fd is used after the first sendto syscall. Also the minimal buffer size calculation uses the wrong size. Fixes #235. --- ports/src/lib/libc_noux/plugin.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ports/src/lib/libc_noux/plugin.cc b/ports/src/lib/libc_noux/plugin.cc index 160a09ea0d..08b9bb7941 100644 --- a/ports/src/lib/libc_noux/plugin.cc +++ b/ports/src/lib/libc_noux/plugin.cc @@ -1373,7 +1373,6 @@ namespace { return -1; } - sysio()->sendto_in.fd = noux_fd(fd->context); sysio()->sendto_in.addrlen = addrlen; Genode::memcpy(&sysio()->sendto_in.dest_addr, dest_addr, addrlen); @@ -1382,8 +1381,9 @@ namespace { char *src = (char *)buf; while (len > 0) { - size_t curr_len = Genode::min(sizeof *sysio()->sendto_in.buf, len); + size_t curr_len = Genode::min(sizeof (sysio()->sendto_in.buf), len); + sysio()->sendto_in.fd = noux_fd(fd->context); sysio()->sendto_in.len = curr_len; Genode::memcpy(sysio()->sendto_in.buf, src, curr_len);