[kaffe] bug in PlainSocketImpl.c
Marc Kleine-Budde
kleine-budde at gmx.de
Wed May 7 03:49:01 PDT 2003
Hi!
I've found a small bug in the nativenet debug of
PlainSocketImpl.c:java_net_PlainSocketImpl_socketAccept
the port is not properly convertet to host order, see attached diff.
regards marc
-------------- next part --------------
Index: libraries/clib/net/PlainSocketImpl.c
===================================================================
RCS file: /gyro/cvs/kangaroo/libraries/clib/net/PlainSocketImpl.c,v
retrieving revision 1.1.1.1.2.1
diff -U20 -r1.1.1.1.2.1 PlainSocketImpl.c
--- libraries/clib/net/PlainSocketImpl.c 2003/03/04 15:07:55 1.1.1.1.2.1
+++ libraries/clib/net/PlainSocketImpl.c 2003/05/07 10:09:39
@@ -265,67 +265,67 @@
* Accept a connection.
*/
void
java_net_PlainSocketImpl_socketAccept(struct Hjava_net_PlainSocketImpl* this, struct Hjava_net_SocketImpl* sock)
{
int r;
int rc;
int alen;
struct sockaddr_in addr;
memset(&addr, 0, sizeof(addr));
#if defined(BSD44)
addr.sin_len = sizeof(addr);
#endif
addr.sin_family = AF_INET;
addr.sin_port = htons(unhand(sock)->localport);
addr.sin_addr.s_addr = htonl(unhand(unhand(sock)->address)->address);
DBG(NATIVENET,
dprintf("socketAccept(%p, localport=%d, addr=%s)\n",
- this, addr.sin_port, ip2str(ntohl(addr.sin_addr.s_addr)));
+ this, ntohs(addr.sin_port), ip2str(ntohl(addr.sin_addr.s_addr)));
)
alen = sizeof(addr);
rc = KACCEPT(unhand(unhand(this)->fd)->fd, (struct sockaddr*)&addr, &alen, unhand(this)->timeout, &r);
if (rc == EINTR) {
SignalError("java.io.InterruptedIOException",
"Accept timed out or was interrupted");
}
if (rc) {
SignalError("java.io.IOException", SYS_ERROR(rc));
}
unhand(unhand(sock)->fd)->fd = r;
/* Enter information into socket object */
alen = sizeof(addr);
r = KGETPEERNAME(r, (struct sockaddr*)&addr, &alen);
if (r) {
SignalError("java.io.IOException", SYS_ERROR(r));
}
unhand(unhand(sock)->address)->address = ntohl(addr.sin_addr.s_addr);
unhand(sock)->port = ntohs(addr.sin_port);
DBG(NATIVENET,
dprintf("socketAccept(%p, localport=-, addr=-) -> (sock: %p; addr: %s; port:%d)\n",
- this, sock, ip2str(ntohl(addr.sin_addr.s_addr)), addr.sin_port);
+ this, sock, ip2str(ntohl(addr.sin_addr.s_addr)), ntohs(addr.sin_port));
)
}
/*
* Return how many bytes can be read without blocking.
*/
jint
java_net_PlainSocketImpl_socketAvailable(struct Hjava_net_PlainSocketImpl* this)
{
int r;
jint len;
int fd;
#if (!(defined(HAVE_IOCTL) && defined(FIONREAD)) && !defined(__WIN32__))
static struct timeval tm = { 0, 0 };
fd_set rd;
#endif
DBG(NATIVENET,
dprintf("socketAvailable(%p)\n", this);
)
-------------- next part --------------
2003-05-07 Marc Kleine-Budde <kleine-budde at gmx.de>
* libraries/clib/net/PlainSocketImpl.c:
(java_net_PlainSocketImpl_socketAccept) DBG NATIVENET
convert port properly from network to host byte order
More information about the kaffe
mailing list