don't allow register on port 0

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@30867 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Richard Frith-MacDonald 2010-06-26 15:22:38 +00:00
parent 3a856711c1
commit b94743cef9
2 changed files with 12 additions and 5 deletions

View file

@ -1,9 +1,10 @@
2010-06-26 Richard Frith-Macdonald <rfm@gnu.org>
* Source/NSObject.m: Remove the Object(NSObjectCompat) category as the
use ogf the Object class is *really* obsolete, and also there appears
use of the Object class is *really* obsolete, and also there appears
to be an objc runtime bug whaich adds the category methods to NSZombie
even though NSZombie is not a subclass of Object.
* Tools/gdomap.c: Avoid strange hang when trying to register on port 0
2010-06-25 Richard Frith-Macdonald <rfm@gnu.org>

View file

@ -2407,7 +2407,7 @@ handle_io()
if (rval < 0 && errno == EBADF)
{
clear_chan(i);
if (i == tcp_desc)
if (i == tcp_desc || i == udp_desc)
{
snprintf(ebuf, sizeof(ebuf),
"Fatal error on socket.");
@ -2833,10 +2833,9 @@ handle_request(int desc)
#endif
}
}
else if (port == 0)
else if (port != 0)
{ /* Port not provided! */
snprintf(ebuf, sizeof(ebuf), "port not provided in request");
gdomap_log(LOG_ERR);
*(unsigned long*)wi->buf = 0;
}
else
{ /* Use port provided in request. */
@ -4074,6 +4073,13 @@ nameServer(const char* name, const char* host, int op, int ptype, struct sockadd
if (op == GDO_REGISTER)
{
port = (unsigned short)pnum;
if (port == 0)
{
snprintf(ebuf, sizeof(ebuf),
"attempted registration with bad port.");
gdomap_log(LOG_ERR);
return -1;
}
}
rval = tryHost(op, len, (unsigned char*)name, ptype, &sin, &port, 0);
if (rval != 0 && host == local_hostname)