OBS User unknown 2006-12-18 23:17:15 +00:00 committed by Git OBS Bridge
commit a9e01b3bd6
24 changed files with 6866 additions and 0 deletions

23
.gitattributes vendored Normal file
View File

@ -0,0 +1,23 @@
## Default LFS
*.7z filter=lfs diff=lfs merge=lfs -text
*.bsp filter=lfs diff=lfs merge=lfs -text
*.bz2 filter=lfs diff=lfs merge=lfs -text
*.gem filter=lfs diff=lfs merge=lfs -text
*.gz filter=lfs diff=lfs merge=lfs -text
*.jar filter=lfs diff=lfs merge=lfs -text
*.lz filter=lfs diff=lfs merge=lfs -text
*.lzma filter=lfs diff=lfs merge=lfs -text
*.obscpio filter=lfs diff=lfs merge=lfs -text
*.oxt filter=lfs diff=lfs merge=lfs -text
*.pdf filter=lfs diff=lfs merge=lfs -text
*.png filter=lfs diff=lfs merge=lfs -text
*.rpm filter=lfs diff=lfs merge=lfs -text
*.tbz filter=lfs diff=lfs merge=lfs -text
*.tbz2 filter=lfs diff=lfs merge=lfs -text
*.tgz filter=lfs diff=lfs merge=lfs -text
*.ttf filter=lfs diff=lfs merge=lfs -text
*.txz filter=lfs diff=lfs merge=lfs -text
*.whl filter=lfs diff=lfs merge=lfs -text
*.xz filter=lfs diff=lfs merge=lfs -text
*.zip filter=lfs diff=lfs merge=lfs -text
*.zst filter=lfs diff=lfs merge=lfs -text

1
.gitignore vendored Normal file
View File

@ -0,0 +1 @@
.osc

55
README.SuSE Normal file
View File

@ -0,0 +1,55 @@
#
# Service Location Protocol on SuSE
#
The Service Location Protcol (SLP) is part of the zerconf concept to provide
service informations inside a local network.
#
# The client side
#
Your client can search for avaible services using the slp library or via
using the slptool binary (for scripting).
WARNING: Have in mind that you can usually NOT trust the results.
It is up to the service client to validate the server.
Do NOT authentificate to an untrusted server or it might be
possible it gets your password.
#
# The server side
#
Every system which provides a service which should get announced with SLP
in the network needs also to run the slpd. There are several possible ways
to announce the service:
1) The authors of any service daemon should directly use libslp to
register the service on the server. Documentation for this can be
found in /usr/share/doc/packages/openslp/html/ProgrammersGuide/
2) Packages without direct SLP support should provide a registration
file in the /etc/slp.reg.d/ directory. See below for a template.
You can use the pseudo attributes watch-port-tcp and watch-port-udp
to make slpd check if the service is listening on the specified port.
This way a not-running service won't get announced by slpd.
3) Administrators can add service lines in the /etc/slp.reg file.
4) The slptool can be used to register a service in any script.
Example of a registration file.
This could be used to announce the sane daemon running on port 6566
------------------------------------------------------------------------
## Register a saned service on this system
## en means english language
## 65535 disables the timeout, so the service registration does
## not need refreshs
service:scanner.sane://$HOSTNAME:6566,en,65535
# only announce the service if a daemon is listening on tcp port 6566
watch-port-tcp=6566
description=SANE scanner daemon
------------------------------------------------------------------------

4044
extensions.diff Normal file

File diff suppressed because it is too large Load Diff

11
hppa.diff Normal file
View File

@ -0,0 +1,11 @@
--- configure.in 2004/06/13 12:17:00 1.1
+++ configure.in 2004/06/13 12:17:19
@@ -125,7 +125,7 @@
CFLAGS="$CFLAGS -Werror"
fi
if test X"$debug" = X"no"; then
- OPTFLAGS="-O3"
+ OPTFLAGS="-O2"
fi
elif $CC -V 2>&1 | grep "WorkShop Compilers"; then

3
openslp-1.2.0.tar.bz2 Normal file
View File

@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:bf2bbe9102405cdfee8f53d6893073ce7e6ccf0be803ca2399180ac0f6f7a178
size 417994

4
openslp-devel.desktop Normal file
View File

@ -0,0 +1,4 @@
[Desktop Entry]
Name=Open SLP Developer Guide
DocPath=/usr/share/doc/packages/openslp/html/ProgrammersGuide/index.html
X-DOC-SearchMethod=htdig

540
openslp.audit.diff Normal file
View File

@ -0,0 +1,540 @@
--- ./common/slp_dhcp.c.orig 2005-02-15 18:28:19.332759386 +0000
+++ ./common/slp_dhcp.c 2005-02-15 18:30:52.797854324 +0000
@@ -598,6 +598,7 @@
cpysz = optdatasz < sizeof(ctxp->scopelist)?
optdatasz: sizeof(ctxp->scopelist);
strncpy(ctxp->scopelist, (char*)p, cpysz);
+ ctxp->scopelist[sizeof(ctxp->scopelist) - 1] = 0;
}
else
{
@@ -622,6 +623,7 @@
cpysz = optdatasz < sizeof(ctxp->scopelist)?
optdatasz: sizeof(ctxp->scopelist);
strncpy(ctxp->scopelist, (char*)p, cpysz);
+ ctxp->scopelist[sizeof(ctxp->scopelist) - 1] = 0;
}
}
break;
--- ./common/slp_message.c.orig 2005-02-15 16:48:20.243994238 +0000
+++ ./common/slp_message.c 2005-02-15 18:17:16.217402037 +0000
@@ -68,6 +68,10 @@
/* header (IN/OUT) pointer to the header structure to fill out */
/*=========================================================================*/
{
+ if (buffer->end - buffer->start < 2)
+ {
+ return SLP_ERROR_PARSE_ERROR;
+ }
header->version = *(buffer->curpos);
header->functionid = *(buffer->curpos + 1);
@@ -75,6 +79,11 @@
{
return SLP_ERROR_VER_NOT_SUPPORTED;
}
+ /* check for invalid length 18 bytes is the smallest v2 message*/
+ if (buffer->end - buffer->start < 18)
+ {
+ return SLP_ERROR_PARSE_ERROR;
+ }
header->length = AsUINT24(buffer->curpos + 2);
header->flags = AsUINT16(buffer->curpos + 5);
header->encoding = 0; /* not used for SLPv2 */
@@ -89,9 +98,7 @@
return SLP_ERROR_PARSE_ERROR;
}
- /* check for invalid length 18 bytes is the smallest v2 message*/
- if(header->length != buffer->end - buffer->start ||
- header->length < 18)
+ if(header->length != buffer->end - buffer->start)
{
return SLP_ERROR_PARSE_ERROR;
}
@@ -187,7 +194,7 @@
/* parse out url */
urlentry->urllen = AsUINT16(buffer->curpos);
buffer->curpos = buffer->curpos + 2;
- if(urlentry->urllen > buffer->end - buffer->curpos)
+ if(urlentry->urllen + 1 > buffer->end - buffer->curpos)
{
return SLP_ERROR_PARSE_ERROR;
}
@@ -235,7 +242,7 @@
/* parse the prlist */
srvrqst->prlistlen = AsUINT16(buffer->curpos);
buffer->curpos = buffer->curpos + 2;
- if(srvrqst->prlistlen > buffer->end - buffer->curpos)
+ if(srvrqst->prlistlen + 2 > buffer->end - buffer->curpos)
{
return SLP_ERROR_PARSE_ERROR;
}
@@ -246,7 +253,7 @@
/* parse the service type */
srvrqst->srvtypelen = AsUINT16(buffer->curpos);
buffer->curpos = buffer->curpos + 2;
- if(srvrqst->srvtypelen > buffer->end - buffer->curpos)
+ if(srvrqst->srvtypelen + 2 > buffer->end - buffer->curpos)
{
return SLP_ERROR_PARSE_ERROR;
}
@@ -257,7 +264,7 @@
/* parse the scope list */
srvrqst->scopelistlen = AsUINT16(buffer->curpos);
buffer->curpos = buffer->curpos + 2;
- if(srvrqst->scopelistlen > buffer->end - buffer->curpos)
+ if(srvrqst->scopelistlen + 2 > buffer->end - buffer->curpos)
{
return SLP_ERROR_PARSE_ERROR;
}
@@ -269,7 +276,7 @@
srvrqst->predicatever = 2; /* SLPv2 predicate (LDAPv3) */
srvrqst->predicatelen = AsUINT16(buffer->curpos);
buffer->curpos = buffer->curpos + 2;
- if(srvrqst->predicatelen > buffer->end - buffer->curpos)
+ if(srvrqst->predicatelen + 2 > buffer->end - buffer->curpos)
{
return SLP_ERROR_PARSE_ERROR;
}
@@ -358,10 +365,14 @@
return result;
}
+ if(buffer->end - buffer->curpos < 2)
+ {
+ return SLP_ERROR_PARSE_ERROR;
+ }
/* parse the service type */
srvreg->srvtypelen = AsUINT16(buffer->curpos);
buffer->curpos = buffer->curpos + 2;
- if(srvreg->srvtypelen > buffer->end - buffer->curpos)
+ if(srvreg->srvtypelen + 2 > buffer->end - buffer->curpos)
{
return SLP_ERROR_PARSE_ERROR;
}
@@ -372,7 +383,7 @@
/* parse the scope list */
srvreg->scopelistlen = AsUINT16(buffer->curpos);
buffer->curpos = buffer->curpos + 2;
- if(srvreg->scopelistlen > buffer->end - buffer->curpos)
+ if(srvreg->scopelistlen + 2 > buffer->end - buffer->curpos)
{
return SLP_ERROR_PARSE_ERROR;
}
@@ -383,7 +394,7 @@
/* parse the attribute list*/
srvreg->attrlistlen = AsUINT16(buffer->curpos);
buffer->curpos = buffer->curpos + 2;
- if(srvreg->attrlistlen > buffer->end - buffer->curpos)
+ if(srvreg->attrlistlen + 1 > buffer->end - buffer->curpos)
{
return SLP_ERROR_PARSE_ERROR;
}
@@ -447,6 +458,10 @@
}
/* parse the tag list */
+ if(buffer->end - buffer->curpos < 2)
+ {
+ return SLP_ERROR_PARSE_ERROR;
+ }
srvdereg->taglistlen = AsUINT16(buffer->curpos);
buffer->curpos = buffer->curpos + 2;
if(srvdereg->taglistlen > buffer->end - buffer->curpos)
@@ -482,7 +497,7 @@
/* parse the prlist */
attrrqst->prlistlen = AsUINT16(buffer->curpos);
buffer->curpos = buffer->curpos + 2;
- if(attrrqst->prlistlen > buffer->end - buffer->curpos)
+ if(attrrqst->prlistlen + 2 > buffer->end - buffer->curpos)
{
return SLP_ERROR_PARSE_ERROR;
}
@@ -492,7 +507,7 @@
/* parse the url */
attrrqst->urllen = AsUINT16(buffer->curpos);
buffer->curpos = buffer->curpos + 2;
- if(attrrqst->urllen > buffer->end - buffer->curpos)
+ if(attrrqst->urllen + 2 > buffer->end - buffer->curpos)
{
return SLP_ERROR_PARSE_ERROR;
}
@@ -503,7 +518,7 @@
/* parse the scope list */
attrrqst->scopelistlen = AsUINT16(buffer->curpos);
buffer->curpos = buffer->curpos + 2;
- if(attrrqst->scopelistlen > buffer->end - buffer->curpos)
+ if(attrrqst->scopelistlen + 2 > buffer->end - buffer->curpos)
{
return SLP_ERROR_PARSE_ERROR;
}
@@ -514,7 +529,7 @@
/* parse the taglist string */
attrrqst->taglistlen = AsUINT16(buffer->curpos);
buffer->curpos = buffer->curpos + 2;
- if(attrrqst->taglistlen > buffer->end - buffer->curpos)
+ if(attrrqst->taglistlen + 2 > buffer->end - buffer->curpos)
{
return SLP_ERROR_PARSE_ERROR;
}
@@ -563,7 +578,7 @@
/* parse out the attrlist */
attrrply->attrlistlen = AsUINT16(buffer->curpos);
buffer->curpos = buffer->curpos + 2;
- if(attrrply->attrlistlen > buffer->end - buffer->curpos)
+ if(attrrply->attrlistlen + 1 > buffer->end - buffer->curpos)
{
return SLP_ERROR_PARSE_ERROR;
}
@@ -619,13 +634,17 @@
buffer->curpos = buffer->curpos + 2;
/* parse out the bootstamp */
+ if(buffer->end - buffer->curpos < 6)
+ {
+ return SLP_ERROR_PARSE_ERROR;
+ }
daadvert->bootstamp = AsUINT32(buffer->curpos);
buffer->curpos = buffer->curpos + 4;
/* parse out the url */
daadvert->urllen = AsUINT16(buffer->curpos);
buffer->curpos = buffer->curpos + 2;
- if(daadvert->urllen > buffer->end - buffer->curpos)
+ if(daadvert->urllen + 2 > buffer->end - buffer->curpos)
{
return SLP_ERROR_PARSE_ERROR;
}
@@ -635,7 +654,7 @@
/* parse the scope list */
daadvert->scopelistlen = AsUINT16(buffer->curpos);
buffer->curpos = buffer->curpos + 2;
- if(daadvert->scopelistlen > buffer->end - buffer->curpos)
+ if(daadvert->scopelistlen + 2 > buffer->end - buffer->curpos)
{
return SLP_ERROR_PARSE_ERROR;
}
@@ -645,7 +664,7 @@
/* parse the attr list */
daadvert->attrlistlen = AsUINT16(buffer->curpos);
buffer->curpos = buffer->curpos + 2;
- if(daadvert->attrlistlen > buffer->end - buffer->curpos)
+ if(daadvert->attrlistlen + 2 > buffer->end - buffer->curpos)
{
return SLP_ERROR_PARSE_ERROR;
}
@@ -655,7 +674,7 @@
/* parse the SPI list */
daadvert->spilistlen = AsUINT16(buffer->curpos);
buffer->curpos = buffer->curpos + 2;
- if(daadvert->spilistlen > buffer->end - buffer->curpos)
+ if(daadvert->spilistlen + 1 > buffer->end - buffer->curpos)
{
return SLP_ERROR_PARSE_ERROR;
}
@@ -704,7 +723,7 @@
/* parse out the url */
saadvert->urllen = AsUINT16(buffer->curpos);
buffer->curpos = buffer->curpos + 2;
- if(saadvert->urllen > buffer->end - buffer->curpos)
+ if(saadvert->urllen + 2 > buffer->end - buffer->curpos)
{
return SLP_ERROR_PARSE_ERROR;
}
@@ -714,7 +733,7 @@
/* parse the scope list */
saadvert->scopelistlen = AsUINT16(buffer->curpos);
buffer->curpos = buffer->curpos + 2;
- if(saadvert->scopelistlen > buffer->end - buffer->curpos)
+ if(saadvert->scopelistlen + 2 > buffer->end - buffer->curpos)
{
return SLP_ERROR_PARSE_ERROR;
}
@@ -724,7 +743,7 @@
/* parse the attr list */
saadvert->attrlistlen = AsUINT16(buffer->curpos);
buffer->curpos = buffer->curpos + 2;
- if(saadvert->attrlistlen > buffer->end - buffer->curpos)
+ if(saadvert->attrlistlen + 1 > buffer->end - buffer->curpos)
{
return SLP_ERROR_PARSE_ERROR;
}
@@ -769,7 +788,7 @@
/* parse the prlist */
srvtyperqst->prlistlen = AsUINT16(buffer->curpos);
buffer->curpos += 2;
- if(srvtyperqst->prlistlen > buffer->end - buffer->curpos)
+ if(srvtyperqst->prlistlen + 2 > buffer->end - buffer->curpos)
{
return SLP_ERROR_PARSE_ERROR;
}
@@ -794,6 +813,10 @@
}
/* parse the scope list */
+ if(buffer->end - buffer->curpos < 2)
+ {
+ return SLP_ERROR_PARSE_ERROR;
+ }
srvtyperqst->scopelistlen = AsUINT16(buffer->curpos);
buffer->curpos += 2;
if(srvtyperqst->scopelistlen > buffer->end - buffer->curpos)
--- ./common/slp_network.c.orig 2005-02-15 17:48:00.831814261 +0000
+++ ./common/slp_network.c 2005-02-15 17:51:29.856000181 +0000
@@ -300,7 +300,7 @@
/* EINVAL parse error */
/*=========================================================================*/
{
- int xferbytes;
+ int xferbytes, recvlen;
fd_set readfds;
char peek[16];
int peeraddrlen = sizeof(struct sockaddr_in);
@@ -359,10 +359,14 @@
/* Read the rest of the message */
/*------------------------------*/
/* check the version */
- if(*peek == 2)
+ if(xferbytes >= 5 && *peek == 2)
{
/* allocate the recvmsg big enough for the whole message */
- *buf = SLPBufferRealloc(*buf, AsUINT24(peek + 2));
+ recvlen = AsUINT24(peek + 2);
+ /* one byte is minimum */
+ if (recvlen <= 0)
+ recvlen = 1;
+ *buf = SLPBufferRealloc(*buf, recvlen);
if(*buf)
{
while((*buf)->curpos < (*buf)->end)
--- ./common/slp_v1message.c.orig 2005-02-15 16:52:12.613798586 +0000
+++ ./common/slp_v1message.c 2005-02-15 18:26:47.632848004 +0000
@@ -60,6 +60,11 @@
/* SLP_ERROR_PARSE_ERROR. */
/*=========================================================================*/
{
+ if (buffer->end - buffer->start < 12)
+ {
+ /* invalid length 12 bytes is the smallest v1 message*/
+ return SLP_ERROR_PARSE_ERROR;
+ }
header->version = *(buffer->curpos);
header->functionid = *(buffer->curpos + 1);
@@ -85,10 +90,8 @@
return SLP_ERROR_CHARSET_NOT_UNDERSTOOD;
}
- if(header->length != buffer->end - buffer->start ||
- header->length < 12)
+ if(header->length != buffer->end - buffer->start)
{
- /* invalid length 12 bytes is the smallest v1 message*/
return SLP_ERROR_PARSE_ERROR;
}
@@ -114,7 +117,7 @@
int result;
/* make sure that min size is met */
- if(buffer->end - buffer->curpos < 6)
+ if(buffer->end - buffer->curpos < 4)
{
return SLP_ERROR_PARSE_ERROR;
}
@@ -160,7 +163,7 @@
int result;
/* make sure that min size is met */
- if(buffer->end - buffer->curpos < 10)
+ if(buffer->end - buffer->curpos < 4)
{
return SLP_ERROR_PARSE_ERROR;
}
@@ -168,7 +171,7 @@
/* parse the prlist */
srvrqst->prlistlen = AsUINT16(buffer->curpos);
buffer->curpos = buffer->curpos + 2;
- if(srvrqst->prlistlen > buffer->end - buffer->curpos)
+ if(srvrqst->prlistlen + 2 > buffer->end - buffer->curpos)
{
return SLP_ERROR_PARSE_ERROR;
}
@@ -272,6 +275,10 @@
srvreg->srvtypelen = tmp - srvreg->srvtype;
/* parse the attribute list */
+ if(buffer->end - buffer->curpos < 2)
+ {
+ return SLP_ERROR_PARSE_ERROR;
+ }
srvreg->attrlistlen = AsUINT16(buffer->curpos);
buffer->curpos = buffer->curpos + 2;
if(srvreg->attrlistlen > buffer->end - buffer->curpos)
@@ -335,7 +342,7 @@
srvdereg->urlentry.lifetime = 0; /* not present in SLPv1 */
srvdereg->urlentry.urllen = AsUINT16(buffer->curpos);
buffer->curpos += 2;
- if(srvdereg->urlentry.urllen > buffer->end - buffer->curpos)
+ if(srvdereg->urlentry.urllen + 2 > buffer->end - buffer->curpos)
{
return SLP_ERROR_PARSE_ERROR;
}
@@ -381,7 +388,7 @@
/* parse the prlist */
attrrqst->prlistlen = AsUINT16(buffer->curpos);
buffer->curpos = buffer->curpos + 2;
- if(attrrqst->prlistlen > buffer->end - buffer->curpos)
+ if(attrrqst->prlistlen + 2 > buffer->end - buffer->curpos)
{
return SLP_ERROR_PARSE_ERROR;
}
@@ -396,7 +403,7 @@
/* parse the url */
attrrqst->urllen = AsUINT16(buffer->curpos);
buffer->curpos = buffer->curpos + 2;
- if(attrrqst->urllen > buffer->end - buffer->curpos)
+ if(attrrqst->urllen + 2 > buffer->end - buffer->curpos)
{
return SLP_ERROR_PARSE_ERROR;
}
@@ -411,7 +418,7 @@
/* parse the scope list */
attrrqst->scopelistlen = AsUINT16(buffer->curpos);
buffer->curpos = buffer->curpos + 2;
- if(attrrqst->scopelistlen > buffer->end - buffer->curpos)
+ if(attrrqst->scopelistlen + 2 > buffer->end - buffer->curpos)
{
return SLP_ERROR_PARSE_ERROR;
}
@@ -469,7 +476,7 @@
/* parse the prlist */
srvtyperqst->prlistlen = AsUINT16(buffer->curpos);
buffer->curpos += 2;
- if(srvtyperqst->prlistlen > buffer->end - buffer->curpos)
+ if(srvtyperqst->prlistlen + 2 > buffer->end - buffer->curpos)
{
return SLP_ERROR_PARSE_ERROR;
}
@@ -504,6 +511,10 @@
}
/* parse the scope list */
+ if(buffer->end - buffer->curpos < 2)
+ {
+ return SLP_ERROR_PARSE_ERROR;
+ }
srvtyperqst->scopelistlen = AsUINT16(buffer->curpos);
buffer->curpos += 2;
if(srvtyperqst->scopelistlen > buffer->end - buffer->curpos)
--- ./libslp/libslp_parse.c.orig 2005-02-15 18:39:01.505072256 +0000
+++ ./libslp/libslp_parse.c 2005-02-15 18:41:21.510075488 +0000
@@ -168,7 +168,10 @@
if((isTag) && strchr(ATTRIBUTE_BAD_TAG, *current_inbuf))
return(SLP_PARSE_ERROR);
- if(strchr(ATTRIBUTE_RESERVE_STRING, *current_inbuf))
+ if((strchr(ATTRIBUTE_RESERVE_STRING, *current_inbuf)) ||
+ ((*current_inbuf >= 0x00) && (*current_inbuf <= 0x1F)) ||
+ (*current_inbuf == 0x7F)
+ )
amount_of_escape_characters++;
current_inbuf++;
--- ./slpd/slpd_incoming.c.orig 2005-02-15 17:01:07.456383345 +0000
+++ ./slpd/slpd_incoming.c 2005-02-15 17:47:18.244888341 +0000
@@ -189,13 +189,16 @@
MSG_PEEK,
(struct sockaddr *)&(sock->peeraddr),
&peeraddrlen);
- if (bytesread > 0)
+ if (bytesread > 0 && bytesread >= (*peek == 2 ? 5 : 4))
{
if (*peek == 2)
recvlen = AsUINT24(peek + 2);
else if (*peek == 1) /* SLPv1 packet */
recvlen = AsUINT16(peek + 2);
+ /* one byte is minimum */
+ if (recvlen <= 0)
+ recvlen = 1;
/* allocate the recvbuf big enough for the whole message */
sock->recvbuf = SLPBufferRealloc(sock->recvbuf,recvlen);
if (sock->recvbuf)
@@ -249,7 +252,7 @@
}
else
{
- /* error in recv() */
+ /* error in recv() or eof */
sock->state = SOCKET_CLOSE;
}
}
--- ./slpd/slpd_outgoing.c.orig 2005-02-15 17:29:22.366303963 +0000
+++ ./slpd/slpd_outgoing.c 2005-02-15 17:46:47.727240947 +0000
@@ -190,7 +190,7 @@
void OutgoingStreamRead(SLPList* socklist, SLPDSocket* sock)
/*-------------------------------------------------------------------------*/
{
- int bytesread;
+ int bytesread, recvlen;
char peek[16];
int peeraddrlen = sizeof(struct sockaddr_in);
@@ -205,10 +205,14 @@
MSG_PEEK,
(struct sockaddr *)&(sock->peeraddr),
&peeraddrlen);
- if ( bytesread > 0 )
+ if ( bytesread >= 5 && *peek == 2 )
{
+ recvlen = AsUINT24(peek + 2);
+ /* one byte is minimum */
+ if (recvlen <= 0)
+ recvlen = 1;
/* allocate the recvbuf big enough for the whole message */
- sock->recvbuf = SLPBufferRealloc(sock->recvbuf,AsUINT24(peek+2));
+ sock->recvbuf = SLPBufferRealloc(sock->recvbuf, recvlen);
if ( sock->recvbuf )
{
sock->state = STREAM_READ;
@@ -219,7 +223,7 @@
sock->state = SOCKET_CLOSE;
}
}
- else
+ else if ( bytesread == -1 )
{
#ifdef _WIN32
if ( WSAEWOULDBLOCK != WSAGetLastError() )
@@ -232,6 +236,10 @@
OutgoingStreamReconnect(socklist,sock);
}
}
+ else
+ {
+ sock->state = SOCKET_CLOSE;
+ }
}
if ( sock->state == STREAM_READ )
--- ./slpd/slpd_v1process.c.orig 2005-02-15 17:05:42.710057099 +0000
+++ ./slpd/slpd_v1process.c 2005-02-15 17:29:06.518563216 +0000
@@ -808,11 +808,16 @@
{
/* SLPv1 messages are handled only by DAs */
errorcode = SLP_ERROR_VER_NOT_SUPPORTED;
+ return errorcode;
}
/* Parse just the message header the reset the buffer "curpos" pointer */
recvbuf->curpos = recvbuf->start;
errorcode = SLPv1MessageParseHeader(recvbuf, &header);
+ if (errorcode != 0)
+ {
+ return errorcode;
+ }
/* TRICKY: Duplicate SRVREG recvbufs *before* parsing them */
/* it because we are going to keep them in the */

258
openslp.changes Normal file
View File

@ -0,0 +1,258 @@
-------------------------------------------------------------------
Thu Nov 16 17:13:01 CET 2006 - mls@suse.de
- truncate oversized udp messages, finally fixes [#185483]
(can be turned of with "net.slp.oversizedUDP" option)
- do not try to send back empty answers
- add option "net.slp.allowDoubleEqualInPredicate" to make openslp
work with some buggy clients that use "==" for comparison [#95043]
- changed SLPGetPeer interface to support IPv6
-------------------------------------------------------------------
Tue Sep 12 15:23:43 CEST 2006 - mls@suse.de
- obey OVERFLOW bit of incoming udp messages [#185483]
- use right length in send() calls [#185483]
- fix errno check in IncomingStreamWrite
- add SLPGetPeer method in libslp
- add --peerinfo option to slptool to print peerinfo
-------------------------------------------------------------------
Wed May 10 20:41:30 CEST 2006 - mls@suse.de
- fix unaligned memory access on ia64 [#171932]
-------------------------------------------------------------------
Fri Mar 24 14:23:39 CET 2006 - mls@suse.de
- fix listening on multiple interfaces [#160008]
-------------------------------------------------------------------
Sat Mar 18 03:33:51 CET 2006 - schwab@suse.de
- Fix file descritor leak [#159303].
-------------------------------------------------------------------
Mon Jan 30 16:35:37 CET 2006 - mls@suse.de
- fix bug in DropSLPMulticastGroup
- add -fstack-protector to CFLAGS
- added logrotate script [#143069]
-------------------------------------------------------------------
Wed Jan 25 21:30:39 CET 2006 - mls@suse.de
- converted neededforbuild to BuildRequires
-------------------------------------------------------------------
Fri Dec 23 15:41:12 CET 2005 - mls@suse.de
- clear overflow bit on TCP connections [#135248]
-------------------------------------------------------------------
Thu Sep 29 03:15:17 CEST 2005 - dmueller@suse.de
- add norootforbuild
-------------------------------------------------------------------
Mon Aug 22 19:31:23 CEST 2005 - mls@suse.de
- also listen on SLPv1 General Multicast address [#64138]
- use poll instead of select [#65673]
-------------------------------------------------------------------
Tue Feb 15 19:52:01 CET 2005 - mls@suse.de
- update to version 1.2.0
- fixed security audit findings
- disable mdns in slpd for now, libslp still supports it
-------------------------------------------------------------------
Fri Dec 3 12:39:40 CET 2004 - mls@suse.de
- fix slpv DA discovery scope handling (#48728)
- use _dns-sd instead of _mdns in mdns findsrvtypes query (#48325)
-------------------------------------------------------------------
Thu Oct 14 13:55:00 CEST 2004 - adrian@suse.de
- add meta information for suse help.
-------------------------------------------------------------------
Sun Jun 13 14:27:28 CEST 2004 - bg@suse.de
- reduce hardcoded optimization from -O3 to -O2 to circumvent
ICE on hppa
-------------------------------------------------------------------
Tue Jun 1 16:17:17 CEST 2004 - mls@suse.de
- added fillup and insserv prereq
-------------------------------------------------------------------
Thu May 27 14:30:41 CEST 2004 - mls@suse.de
- use /proc/net/tcp_listen and /proc/net/tcp6_listen if
available to keep things fast on systems with lots of
network connections [#40888]
-------------------------------------------------------------------
Wed May 5 20:08:02 CEST 2004 - mls@suse.de
- treat empty attributes as illegal [#39669]
- always start slpd on SLES [#39863]
-------------------------------------------------------------------
Fri Apr 23 12:04:20 CEST 2004 - mls@suse.de
- libslp: use configured TTL settings [#39030]
-------------------------------------------------------------------
Fri Apr 2 12:17:42 CEST 2004 - mls@suse.de
- beta is over, don't always start slpd
-------------------------------------------------------------------
Fri Apr 2 09:18:03 CEST 2004 - kukuk@suse.de
- Fix init script
-------------------------------------------------------------------
Wed Mar 31 13:03:35 CEST 2004 - mls@suse.de
- fix sighup processing
- clean up spi code
- fix spi null pointer reference
- fix namingauth comparison
- added try-restart to rcslpd
- fix slp.conf re-read
- fix prlist buffer overrun
-------------------------------------------------------------------
Mon Mar 29 14:58:00 CEST 2004 - mls@suse.de
- turn around srvtypes order in mdns
-------------------------------------------------------------------
Thu Mar 18 17:12:34 CET 2004 - mls@suse.de
- code cleanup
- provide A RR with SRV RRs
- don't pack .xvpics
-------------------------------------------------------------------
Fri Mar 12 15:48:09 CET 2004 - mls@suse.de
- added missing SLPGetMDNSName prototype to slp.h
-------------------------------------------------------------------
Fri Mar 12 12:38:38 CET 2004 - mls@suse.de
- slpd: fix hostname detection segfault
- slpd: use ttl 255 for mdns
- slpd: put attrs in mdns TXT RR
- libslp: check mdns ttl
- libslp: make getattr work with mdns
- libslp: make mdns name available via new SLPGetMDNSName() function
-------------------------------------------------------------------
Thu Mar 4 18:45:35 CET 2004 - mls@suse.de
- libslp: add scope/nameingauth/predicate to query
- slpd: reply to mdns service requests
- slpd: don't play DA if our hostname expands to loopback
- slpd: fix null pointer reference if SrvReg request is sent
over tcp (as done by apple)
-------------------------------------------------------------------
Fri Feb 27 18:07:46 CET 2004 - mls@suse.de
- slpd: check port status every 15 seconds for watch-port-tcp/udp
entries
- libslp: send MDNS queries for scope _mdns
-------------------------------------------------------------------
Sun Feb 15 18:17:19 CET 2004 - adrian@suse.de
- export full qualified hostnames for $HOSTNAME
- replace several $HOSTNAME tags in a srvurl
- do only accept .reg files (no .rpmsave for instance)
-------------------------------------------------------------------
Sat Feb 14 01:33:22 CET 2004 - adrian@suse.de
- fix /proc/net/tcp* parsing
- ONLY FOR BETA: start slpd always
-------------------------------------------------------------------
Thu Jan 29 13:59:26 CET 2004 - adrian@suse.de
- fix reading from slpd.reg.d directory
(was broken since chroot run)
-------------------------------------------------------------------
Wed Jan 14 13:42:41 CET 2004 - adrian@suse.de
- slptool register now services with max timeout.
-------------------------------------------------------------------
Tue Dec 16 09:14:12 CET 2003 - adrian@suse.de
- fix sig11 when using the library without spi file
-------------------------------------------------------------------
Mon Dec 8 12:06:21 CET 2003 - adrian@suse.de
- security enhancements:
* use chroot and open needed file descriptors before
* panic if chroot or setuid fails
* pid-file= option in reg files is useless now, so
tcp-port= must be used for this now
- add SSL support again
-------------------------------------------------------------------
Wed Nov 26 15:53:52 CET 2003 - adrian@suse.de
- add buffer fix from cvs
- add README.SuSE with config howto
-------------------------------------------------------------------
Thu Nov 20 13:06:13 CET 2003 - adrian@suse.de
- drop the multicast route creation in runlevel script.
we do not need it anymore with 1.1.5
-------------------------------------------------------------------
Wed Nov 19 16:45:08 CET 2003 - adrian@suse.de
- update to version 1.1.5
* development version, but it contains lots of fixes
- use $HOSTNAME instead of $LOCALHOST in reg files
-------------------------------------------------------------------
Fri Nov 14 10:53:01 CET 2003 - adrian@suse.de
- use correct keyword "X-UnitedLinux-Should-Start" in init script
(seen by Martin Vidner)
-------------------------------------------------------------------
Thu Nov 13 22:58:49 CET 2003 - adrian@suse.de
- add "tcp-port=" option to test services running via (x)inted
- start after (x)inetd
-------------------------------------------------------------------
Wed Nov 12 13:28:17 CET 2003 - adrian@suse.de
- add code to parse .reg files from any package below /etc/slp.reg.d/
-------------------------------------------------------------------
Sun Nov 9 23:26:04 CET 2003 - adrian@suse.de
- fix security issue in init script
-------------------------------------------------------------------
Sat Nov 8 17:56:38 CET 2003 - adrian@suse.de
- initial package of version 1.0.11

57
openslp.checkovr.diff Normal file
View File

@ -0,0 +1,57 @@
--- ./common/slp_xcast.c.orig 2006-06-20 14:52:11.000000000 +0000
+++ ./common/slp_xcast.c 2006-06-26 10:08:42.000000000 +0000
@@ -75,6 +75,7 @@
#include "slp_xcast.h"
#include "slp_message.h"
+#include "slp_v1message.h"
#include "slp_property.h"
/*========================================================================*/
@@ -354,14 +355,26 @@ int SLPXcastRecvMessage(const SLPXcastSo
#endif
)
{
- if(AsUINT24(peek + 2) <= SLP_MAX_DATAGRAM_SIZE)
+ int ovlbit;
+ size_t size;
+ if (peek[0] == 1)
{
- *buf = SLPBufferRealloc(*buf, AsUINT24(peek + 2));
+ size = AsUINT16(peek + 2);
+ ovlbit = peek[4] & SLPv1_FLAG_OVERFLOW;
+ }
+ else
+ {
+ size = AsUINT24(peek + 2);
+ ovlbit = peek[5] & (SLP_FLAG_OVERFLOW >> 8);
+ }
+ if(size <= SLP_MAX_DATAGRAM_SIZE && !ovlbit)
+ {
+ *buf = SLPBufferRealloc(*buf, size);
bytesread = recv(sockets->sock[i],
(*buf)->curpos,
(*buf)->end - (*buf)->curpos,
0);
- if(bytesread != AsUINT24(peek + 2))
+ if(bytesread != size)
{
/* This should never happen but we'll be paranoid*/
(*buf)->end = (*buf)->curpos + bytesread;
@@ -377,12 +390,14 @@ int SLPXcastRecvMessage(const SLPXcastSo
/* we got a bad message, or one that is too big! */
#ifndef UNICAST_NOT_SUPPORTED
/* Reading SLP_MAX_DATAGRAM_SIZE bytes on the socket */
- *buf = SLPBufferRealloc(*buf, SLP_MAX_DATAGRAM_SIZE);
+ if (size > SLP_MAX_DATAGRAM_SIZE)
+ size = SLP_MAX_DATAGRAM_SIZE;
+ *buf = SLPBufferRealloc(*buf, size);
bytesread = recv(sockets->sock[i],
(*buf)->curpos,
(*buf)->end - (*buf)->curpos,
0);
- if(bytesread != SLP_MAX_DATAGRAM_SIZE)
+ if(bytesread != size)
{
/* This should never happen but we'll be paranoid*/
(*buf)->end = (*buf)->curpos + bytesread;

4
openslp.desktop Normal file
View File

@ -0,0 +1,4 @@
[Desktop Entry]
Name=Open SLP User Guide
DocPath=/usr/share/doc/packages/openslp/html/UsersGuide/index.html
X-DOC-SearchMethod=htdig

136
openslp.diff Normal file
View File

@ -0,0 +1,136 @@
--- ./common/slp_iface.c.orig 2006-09-12 13:17:00.000000000 +0000
+++ ./common/slp_iface.c 2006-09-12 13:17:08.000000000 +0000
@@ -128,6 +128,7 @@ int SLPIfaceGetInfo(const char* useiface
#endif
{
perror("ioctl failed");
+ close(fd);
return 1;
}
@@ -183,6 +184,7 @@ int SLPIfaceGetInfo(const char* useiface
}
}
+ close(fd);
return 0;
}
#else
--- ./common/slp_net.c.orig 2006-09-12 13:17:00.000000000 +0000
+++ ./common/slp_net.c 2006-09-12 13:17:08.000000000 +0000
@@ -92,7 +92,7 @@ int SLPNetGetThisHostname(char** hostfdn
}
else
{
- ifaddr.s_addr = *((unsigned long*)he->h_addr);
+ ifaddr = *((struct in_addr *)he->h_addr);
*hostfdn = xstrdup(inet_ntoa(ifaddr));
}
--- ./common/slp_spi.c.orig 2006-09-12 13:17:00.000000000 +0000
+++ ./common/slp_spi.c 2006-09-12 13:17:08.000000000 +0000
@@ -267,9 +267,9 @@ SLPSpiHandle SLPSpiOpen(const char* spif
fp = fopen(spifile,"r");
if(fp)
{
- result = xmalloc(sizeof(structSLPSpiHandle));
+ result = xmalloc(sizeof(struct _SLPSpiHandle));
if(result == 0) return 0;
- memset(result, 0, sizeof(structSLPSpiHandle));
+ memset(result, 0, sizeof(struct _SLPSpiHandle));
result->spifile = xstrdup(spifile);
result->cacheprivate = cacheprivate;
--- ./configure.in.orig 2006-09-12 13:17:00.000000000 +0000
+++ ./configure.in 2006-09-12 13:17:08.000000000 +0000
@@ -171,5 +171,12 @@ AC_CHECK_LIB(socket, main)
AC_CHECK_LIB(nsl, gethostbyname)
AC_CHECK_LIB(m, main)
AC_CHECK_FUNCS(ceil log10 strncasecmp strcasecmp )
-AC_OUTPUT(Makefile common/Makefile libslpattr/Makefile libslp/Makefile \
- slpd/Makefile slptool/Makefile test/Makefile slp.list)
+AC_CONFIG_FILES([ Makefile ])
+AC_CONFIG_FILES([ common/Makefile ])
+AC_CONFIG_FILES([ libslpattr/Makefile ])
+AC_CONFIG_FILES([ libslp/Makefile ])
+AC_CONFIG_FILES([ slpd/Makefile ])
+AC_CONFIG_FILES([ slptool/Makefile ])
+AC_CONFIG_FILES([ test/Makefile ])
+AC_CONFIG_FILES([ slp.list ])
+AC_OUTPUT
--- ./etc/slp.reg.orig 2006-09-12 13:17:00.000000000 +0000
+++ ./etc/slp.reg 2006-09-12 13:17:08.000000000 +0000
@@ -37,3 +37,10 @@
##Register telnet service with no attributes
#service:telnet.myorg://192.168.100.1,en,65535
#use default scopes
+
+##Register vnc kdm service, can be used via krdc
+#service:remotedesktop.kde:vnc://192.168.100.1:1,en,65535
+#attrid=(type=shared),(username=joe),(fullname=Joe User),(serviceid=1235456)
+#description=KDE remote login
+
+
--- ./slpd/slpd_incoming.c.orig 2006-09-12 13:17:00.000000000 +0000
+++ ./slpd/slpd_incoming.c 2006-09-12 13:19:18.000000000 +0000
@@ -137,11 +137,11 @@ void IncomingStreamWrite(SLPList* sockli
sock->state = STREAM_WRITE;
}
- if (sock->sendbuf->end - sock->sendbuf->start != 0)
+ if (sock->sendbuf->end - sock->sendbuf->curpos != 0)
{
byteswritten = send(sock->fd,
sock->sendbuf->curpos,
- sock->sendbuf->end - sock->sendbuf->start,
+ sock->sendbuf->end - sock->sendbuf->curpos,
flags);
if (byteswritten > 0)
{
@@ -157,9 +157,9 @@ void IncomingStreamWrite(SLPList* sockli
else
{
#ifdef _WIN32
- if (WSAEWOULDBLOCK == WSAGetLastError())
+ if (WSAEWOULDBLOCK != WSAGetLastError())
#else
- if (errno == EWOULDBLOCK)
+ if (errno != EWOULDBLOCK)
#endif
{
/* Error occured or connection was closed */
@@ -516,6 +516,7 @@ int SLPDIncomingInit()
/* Create socket that will handle multicast UDP. */
/*----------------------------------------------------------------*/
+ mcastaddr.s_addr = htonl(SLP_MCAST_ADDRESS);
sock = SLPDSocketCreateBoundDatagram(&myaddr,
&mcastaddr,
DATAGRAM_MULTICAST);
--- ./slpd/slpd_outgoing.c.orig 2002-12-03 21:04:54.000000000 +0000
+++ ./slpd/slpd_outgoing.c 2006-09-12 13:19:47.000000000 +0000
@@ -328,11 +328,11 @@ void OutgoingStreamWrite(SLPList* sockli
sock->state = STREAM_WRITE;
}
- if ( sock->sendbuf->end - sock->sendbuf->start > 0 )
+ if ( sock->sendbuf->end - sock->sendbuf->curpos > 0 )
{
byteswritten = send(sock->fd,
sock->sendbuf->curpos,
- sock->sendbuf->end - sock->sendbuf->start,
+ sock->sendbuf->end - sock->sendbuf->curpos,
flags);
if ( byteswritten > 0 )
{
--- ./slpd/slpd_socket.c.orig 2006-09-12 13:17:00.000000000 +0000
+++ ./slpd/slpd_socket.c 2006-09-12 13:17:08.000000000 +0000
@@ -183,7 +183,7 @@ int DropSLPMulticastGroup(sockfd_t sockf
memcpy(&mreq.imr_multiaddr, maddr, sizeof(struct in_addr));
/* drop for the specified interface */
- memcpy(&mreq.imr_interface,addr,sizeof(addr));
+ memcpy(&mreq.imr_interface,addr,sizeof(struct in_addr));
return setsockopt(sockfd, IPPROTO_IP, IP_DROP_MEMBERSHIP, (char*)&mreq,sizeof(mreq));
}

59
openslp.doubleequal.diff Normal file
View File

@ -0,0 +1,59 @@
--- slpd/slpd_predicate.c.orig 2006-11-16 12:40:22.000000000 +0100
+++ slpd/slpd_predicate.c 2006-11-16 12:45:22.000000000 +0100
@@ -78,10 +78,11 @@
*********/
#include <assert.h>
-#include <ctype.h>
+#include <ctype.h>
#include <stdlib.h>
#include "slpd_predicate.h"
+#include "slpd_property.h"
#include "../libslpattr/libslpattr.h"
#include "../libslpattr/libslpattr_internal.h"
@@ -1389,6 +1390,10 @@
}
}
+ if (op == EQUAL && G_SlpdProperty.allowDoubleEqualInPredicate && operator[1] == '=')
+ {
+ val_start++;
+ }
/***** Get operands. *****/
/**** Left. ****/
--- slpd/slpd_property.h.orig2 2006-11-16 12:43:26.000000000 +0100
+++ slpd/slpd_property.h 2006-11-16 12:43:48.000000000 +0100
@@ -95,6 +95,7 @@
int checkSourceAddr;
int DAHeartBeat;
int oversizedUDP;
+ int allowDoubleEqualInPredicate;
}SLPDProperty;
--- slpd/slpd_property.c.orig2 2006-11-16 12:42:24.000000000 +0100
+++ slpd/slpd_property.c 2006-11-16 12:43:11.000000000 +0100
@@ -132,6 +132,7 @@
G_SlpdProperty.checkSourceAddr = SLPPropertyAsBoolean(SLPPropertyGet("net.slp.checkSourceAddr"));
G_SlpdProperty.DAHeartBeat = SLPPropertyAsInteger(SLPPropertyGet("net.slp.DAHeartBeat"));
G_SlpdProperty.oversizedUDP = SLPPropertyAsBoolean(SLPPropertyGet("net.slp.oversizedUDP"));
+ G_SlpdProperty.allowDoubleEqualInPredicate = SLPPropertyAsBoolean(SLPPropertyGet("net.slp.allowDoubleEqualInPredicate"));
/*-------------------------------------*/
--- test/SLPD_predicate_test/slpd_predicate_test.c.orig 2006-11-16 13:09:05.000000000 +0100
+++ test/SLPD_predicate_test/slpd_predicate_test.c 2006-11-16 13:10:31.000000000 +0100
@@ -5,6 +5,10 @@
#ifdef ENABLE_PREDICATES
+#include <slpd_property.h>
+
+SLPDProperty G_SlpdProperty;
+
typedef void* SLPDPredicate;
int SLPDPredicateTest(SLPDPredicate predicate, SLPAttributes attr);

20
openslp.emptyanswer.diff Normal file
View File

@ -0,0 +1,20 @@
--- slpd/slpd_incoming.c.orig 2006-11-16 12:19:04.000000000 +0100
+++ slpd/slpd_incoming.c 2006-11-16 12:22:00.000000000 +0100
@@ -251,10 +251,16 @@
sock->state = SOCKET_CLOSE;
break;
default:
+ if (!sock->sendbuf || sock->sendbuf->end == sock->sendbuf->start)
+ {
+ /* no answer available, just close socket */
+ sock->state = SOCKET_CLOSE;
+ break;
+ }
/* some clients cannot cope with the OVERFLOW
* bit set on a TCP stream, so always clear it
*/
- if (sock->sendbuf && sock->sendbuf->end - sock->sendbuf->start > 5)
+ if (sock->sendbuf->end - sock->sendbuf->start > 5)
{
if (sock->sendbuf->start[0] == 1)
sock->sendbuf->start[4] &= ~SLPv1_FLAG_OVERFLOW;

14
openslp.logrotate Normal file
View File

@ -0,0 +1,14 @@
/var/log/slpd.log {
compress
dateext
maxage 14
rotate 99
size +1024k
notifempty
missingok
create 600 root root
sharedscripts
postrotate
/etc/init.d/slpd restart
endscript
}

853
openslp.poll.diff Normal file
View File

@ -0,0 +1,853 @@
--- ./common/slp_dhcp.c.orig 2005-08-22 17:24:56.813080069 +0000
+++ ./common/slp_dhcp.c 2005-08-22 17:25:15.753392664 +0000
@@ -69,6 +69,9 @@
#include <bits/ioctls.h>
#include <sys/time.h>
#endif
+#ifdef HAVE_POLL
+#include <sys/poll.h>
+#endif
#include <stdlib.h>
#include <string.h>
@@ -166,7 +169,11 @@ static int dhcpSendRequest(int sockfd, v
ETIMEDOUT read timed out
=========================================================================*/
{
+#ifdef HAVE_POLL
+ struct pollfd writefd;
+#else
fd_set writefds;
+#endif
int xferbytes;
int flags = 0;
@@ -174,10 +181,17 @@ static int dhcpSendRequest(int sockfd, v
flags = MSG_NOSIGNAL;
#endif
+#ifdef HAVE_POLL
+ writefd.fd = sockfd;
+ writefd.events = POLLOUT;
+ writefd.revents = 0;
+ xferbytes = poll(&writefd, 1, timeout ? timeout->tv_sec * 1000 + timeout->tv_usec / 1000 : -1);
+#else
FD_ZERO(&writefds);
FD_SET(sockfd, &writefds);
-
- if((xferbytes = select(sockfd + 1, 0, &writefds, 0, timeout)) > 0)
+ xferbytes = select(sockfd + 1, 0, &writefds, 0, timeout);
+#endif
+ if(xferbytes > 0)
{
if((xferbytes = sendto(sockfd, (char*)buf, (int)bufsz, flags,
peeraddr, sizeof(struct sockaddr_in))) <= 0)
@@ -214,12 +228,23 @@ static int dhcpRecvResponse(int sockfd,
=========================================================================*/
{
int xferbytes;
+#ifdef HAVE_POLL
+ struct pollfd readfd;
+#else
fd_set readfds;
+#endif
+#ifdef HAVE_POLL
+ readfd.fd = sockfd;
+ readfd.events = POLLIN;
+ readfd.revents = 0;
+ xferbytes = poll(&readfd, 1, timeout ? timeout->tv_sec * 1000 + timeout->tv_usec / 1000 : -1);
+#else
FD_ZERO(&readfds);
FD_SET(sockfd, &readfds);
-
- if((xferbytes = select(sockfd + 1, &readfds, 0 , 0, timeout)) > 0)
+ xferbytes = select(sockfd + 1, &readfds, 0 , 0, timeout);
+#endif
+ if(xferbytes > 0)
{
if((xferbytes = recvfrom(sockfd, (char*)buf, (int)bufsz, 0, 0, 0)) <= 0)
{
--- ./common/slp_network.c.orig 2005-08-22 17:24:56.814079927 +0000
+++ ./common/slp_network.c 2005-08-22 17:25:15.754392523 +0000
@@ -221,7 +221,11 @@ int SLPNetworkSendMessage(int sockfd,
/* ETIME read timed out */
/*=========================================================================*/
{
+#ifdef HAVE_POLL
+ struct pollfd writefd;
+#else
fd_set writefds;
+#endif
int xferbytes;
int flags = 0;
@@ -233,10 +237,17 @@ int SLPNetworkSendMessage(int sockfd,
while(buf->curpos < buf->end)
{
+#ifdef HAVE_POLL
+ writefd.fd = sockfd;
+ writefd.events = POLLOUT;
+ writefd.revents = 0;
+ xferbytes = poll(&writefd, 1, timeout ? timeout->tv_sec * 1000 + timeout->tv_usec / 1000 : -1);
+#else
FD_ZERO(&writefds);
FD_SET(sockfd, &writefds);
xferbytes = select(sockfd + 1, 0, &writefds, 0, timeout);
+#endif
if(xferbytes > 0)
{
if(socktype == SOCK_DGRAM)
@@ -301,16 +312,27 @@ int SLPNetworkRecvMessage(int sockfd,
/*=========================================================================*/
{
int xferbytes, recvlen;
+#ifdef HAVE_POLL
+ struct pollfd readfd;
+#else
fd_set readfds;
+#endif
char peek[16];
int peeraddrlen = sizeof(struct sockaddr_in);
/*---------------------------------------------------------------*/
/* take a peek at the packet to get version and size information */
/*---------------------------------------------------------------*/
+#ifdef HAVE_POLL
+ readfd.fd = sockfd;
+ readfd.events = POLLIN;
+ readfd.revents = 0;
+ xferbytes = poll(&readfd, 1, timeout ? timeout->tv_sec * 1000 + timeout->tv_usec / 1000 : -1);
+#else
FD_ZERO(&readfds);
FD_SET(sockfd, &readfds);
xferbytes = select(sockfd + 1, &readfds, 0 , 0, timeout);
+#endif
if(xferbytes > 0)
{
if(socktype == SOCK_DGRAM)
@@ -371,9 +393,16 @@ int SLPNetworkRecvMessage(int sockfd,
{
while((*buf)->curpos < (*buf)->end)
{
+#ifdef HAVE_POLL
+ readfd.fd = sockfd;
+ readfd.events = POLLIN;
+ readfd.revents = 0;
+ xferbytes = poll(&readfd, 1, timeout ? timeout->tv_sec * 1000 + timeout->tv_usec / 1000 : -1);
+#else
FD_ZERO(&readfds);
FD_SET(sockfd, &readfds);
xferbytes = select(sockfd + 1, &readfds, 0 , 0, timeout);
+#endif
if(xferbytes > 0)
{
xferbytes = recv(sockfd,
--- ./common/slp_network.h.orig 2005-08-22 17:24:56.815079785 +0000
+++ ./common/slp_network.h 2005-08-22 17:25:15.754392523 +0000
@@ -72,6 +72,9 @@
#include <fcntl.h>
#include <errno.h>
#endif
+#ifdef HAVE_POLL
+#include <sys/poll.h>
+#endif
#include "slp_buffer.h"
#include "slp_property.h"
--- ./common/slp_xcast.c.orig 2005-08-22 17:24:56.815079785 +0000
+++ ./common/slp_xcast.c 2005-08-22 17:25:15.755392381 +0000
@@ -65,6 +65,9 @@
#include <fcntl.h>
#include <errno.h>
#endif
+#ifdef HAVE_POLL
+#include <sys/poll.h>
+#endif
#ifndef UNICAST_NOT_SUPPORTED
#include "../libslp/slp.h"
@@ -281,8 +284,12 @@ int SLPXcastRecvMessage(const SLPXcastSo
 *    Zero on success, non-zero with errno set on failure.
 *========================================================================*/
{
+#ifdef HAVE_POLL
+ struct pollfd readfds[SLP_MAX_IFACES];
+#else
fd_set readfds;
int highfd;
+#endif
int i;
int readable;
size_t bytesread;
@@ -295,6 +302,15 @@ int SLPXcastRecvMessage(const SLPXcastSo
recvloop = 1;
while(recvloop)
{
+#ifdef HAVE_POLL
+ for (i=0; i<sockets->sock_count; i++)
+ {
+ readfds[i].fd = sockets->sock[i];
+ readfds[i].events = POLLIN;
+ readfds[i].revents = 0;
+ }
+ readable = poll(readfds, sockets->sock_count, timeout ? timeout->tv_sec * 1000 + timeout->tv_usec / 1000 : -1);
+#else
/* Set the readfds */
FD_ZERO(&readfds);
highfd = 0;
@@ -309,12 +325,17 @@ int SLPXcastRecvMessage(const SLPXcastSo
/* Select */
readable = select(highfd + 1,&readfds,NULL,NULL,timeout);
+#endif
if(readable > 0)
{
/* Read the datagram */
for (i=0; i<sockets->sock_count; i++)
{
+#ifdef HAVE_POLL
+ if((readfds[i].revents & POLLIN) != 0)
+#else
if(FD_ISSET(sockets->sock[i],&readfds))
+#endif
{
/* Peek at the first 16 bytes of the header */
bytesread = recvfrom(sockets->sock[i],
--- ./configure.in.orig 2005-08-22 17:24:56.816079643 +0000
+++ ./configure.in 2005-08-22 17:25:15.756392239 +0000
@@ -170,7 +170,7 @@ AC_CHECK_LIB(resolv, inet_aton)
AC_CHECK_LIB(socket, main)
AC_CHECK_LIB(nsl, gethostbyname)
AC_CHECK_LIB(m, main)
-AC_CHECK_FUNCS(ceil log10 strncasecmp strcasecmp )
+AC_CHECK_FUNCS(ceil log10 strncasecmp strcasecmp poll )
AC_CONFIG_FILES([ Makefile ])
AC_CONFIG_FILES([ common/Makefile ])
AC_CONFIG_FILES([ libslpattr/Makefile ])
--- ./libslp/libslp_mdns.c.orig 2005-08-22 17:24:56.817079502 +0000
+++ ./libslp/libslp_mdns.c 2005-08-22 17:25:15.757392097 +0000
@@ -742,8 +742,12 @@ int SLPMDNSXcastRecvMessage(const SLPXca
* Zero on success, non-zero with errno set on failure.
*========================================================================*/
{
+#ifdef HAVE_POLL
+ struct pollfd readfds[SLP_MAX_IFACES * 2];
+#else
fd_set readfds;
int highfd;
+#endif
int i;
int readable;
size_t bytesread;
@@ -761,6 +765,21 @@ int SLPMDNSXcastRecvMessage(const SLPXca
recvloop = 1;
while(recvloop)
{
+#ifdef HAVE_POLL
+ for (i=0; i<sockets->sock_count; i++)
+ {
+ readfds[i].fd = sockets->sock[i];
+ readfds[i].events = POLLIN;
+ readfds[i].revents = 0;
+ }
+ for (i=0; i<mdnssockets->sock_count; i++)
+ {
+ readfds[i + sockets->sock_count].fd = mdnssockets->sock[i];
+ readfds[i + sockets->sock_count].events = POLLIN;
+ readfds[i + sockets->sock_count].revents = 0;
+ }
+ readable = poll(readfds, sockets->sock_count + mdnssockets->sock_count, timeout ? timeout->tv_sec * 1000 + timeout->tv_usec / 1000 : -1);
+#else
/* Set the readfds */
FD_ZERO(&readfds);
highfd = 0;
@@ -779,12 +798,17 @@ int SLPMDNSXcastRecvMessage(const SLPXca
/* Select */
readable = select(highfd + 1,&readfds,NULL,NULL,timeout);
+#endif
if(readable > 0)
{
/* Read the datagram */
for (i=0; i<sockets->sock_count; i++)
{
+#ifdef HAVE_POLL
+ if((readfds[i].revents & POLLIN) != 0)
+#else
if(FD_ISSET(sockets->sock[i],&readfds))
+#endif
{
/* Peek at the first 16 bytes of the header */
bytesread = recvfrom(sockets->sock[i],
@@ -850,7 +874,11 @@ int SLPMDNSXcastRecvMessage(const SLPXca
}
for (i=0; i<mdnssockets->sock_count; i++)
{
+#ifdef HAVE_POLL
+ if((readfds[sockets->sock_count + i].revents & POLLIN) == 0)
+#else
if(!FD_ISSET(mdnssockets->sock[i],&readfds))
+#endif
continue;
*buf = SLPBufferRealloc(*buf, 8000);
(*buf)->curpos = (*buf)->start;
--- ./slpd/slpd_incoming.c.orig 2005-08-22 17:24:56.818079360 +0000
+++ ./slpd/slpd_incoming.c 2005-08-22 17:25:15.758391955 +0000
@@ -313,23 +313,20 @@ void IncomingSocketListen(SLPList* sockl
/*=========================================================================*/
void SLPDIncomingHandler(int* fdcount,
- fd_set* readfds,
- fd_set* writefds)
+ SLPD_fdset *fdset)
/* Handles all outgoing requests that are pending on the specified file */
/* discriptors */
/* */
-/* fdcount (IN/OUT) number of file descriptors marked in fd_sets */
+/* fdcount (IN/OUT) number of file descriptors marked in fdset */
/* */
-/* readfds (IN) file descriptors with pending read IO */
-/* */
-/* writefds (IN) file descriptors with pending read IO */
+/* fdset (IN) file descriptors with pending read/write IO */
/*=========================================================================*/
{
SLPDSocket* sock;
sock = (SLPDSocket*) G_IncomingSocketList.head;
while (sock && *fdcount)
{
- if (FD_ISSET(sock->fd,readfds))
+ if (SLPD_fdset_readok(fdset, sock))
{
switch (sock->state)
{
@@ -354,7 +351,7 @@ void SLPDIncomingHandler(int* fdcount,
*fdcount = *fdcount - 1;
}
- else if (FD_ISSET(sock->fd,writefds))
+ else if (SLPD_fdset_writeok(fdset, sock))
{
switch (sock->state)
{
--- ./slpd/slpd_incoming.h.orig 2005-08-22 17:24:56.818079360 +0000
+++ ./slpd/slpd_incoming.h 2005-08-22 17:25:15.758391955 +0000
@@ -57,6 +57,7 @@
/* common code includes */
/*=========================================================================*/
#include "slp_linkedlist.h"
+#include "slpd_socket.h"
/*=========================================================================*/
@@ -74,16 +75,13 @@ void SLPDIncomingAge(time_t seconds);
/*=========================================================================*/
void SLPDIncomingHandler(int* fdcount,
- fd_set* readfds,
- fd_set* writefds);
+ SLPD_fdset *fdset);
/* Handles all outgoing requests that are pending on the specified file */
/* discriptors */
/* */
-/* fdcount (IN/OUT) number of file descriptors marked in fd_sets */
+/* fdcount (IN/OUT) number of file descriptors marked in fdset */
/* */
-/* readfds (IN) file descriptors with pending read IO */
-/* */
-/* writefds (IN) file descriptors with pending read IO */
+/* fdset (IN) file descriptors with pending read/write IO */
/*=========================================================================*/
--- ./slpd/slpd_main.c.orig 2005-08-22 17:29:17.587046733 +0000
+++ ./slpd/slpd_main.c 2005-08-22 17:28:13.043216959 +0000
@@ -82,12 +82,11 @@ int G_SIGINT; /* Signal being used for
#endif
/*==========================================================================*/
+#ifdef HAVE_POLL
/*-------------------------------------------------------------------------*/
-void LoadFdSets(SLPList* socklist,
- int* highfd,
- fd_set* readfds,
- fd_set* writefds)
+void LoadFdSets(SLPList* socklist,
+ SLPD_fdset *fdset)
/*-------------------------------------------------------------------------*/
{
SLPDSocket* sock = 0;
@@ -96,9 +95,87 @@ void LoadFdSets(SLPList* socklist,
sock = (SLPDSocket*)socklist->head;
while(sock)
{
- if(sock->fd > *highfd)
+ if (fdset->used == fdset->allocated) {
+ fdset->allocated += 32;
+ if (fdset->used)
+ fdset->fds = xrealloc(fdset->fds, fdset->allocated * sizeof(*fdset->fds));
+ else
+ fdset->fds = xmalloc(fdset->allocated * sizeof(*fdset->fds));
+ if (!fdset->fds)
+ SLPDFatal("No memory for fdset.\n");
+ }
+ fdset->fds[fdset->used].fd = sock->fd;
+ fdset->fds[fdset->used].events = 0;
+ fdset->fds[fdset->used].revents = 0;
+ switch(sock->state)
+ {
+ case DATAGRAM_UNICAST:
+ case DATAGRAM_MULTICAST:
+ case DATAGRAM_BROADCAST:
+ fdset->fds[fdset->used].events |= POLLIN;
+ break;
+
+ case SOCKET_LISTEN:
+ if(socklist->count < SLPD_MAX_SOCKETS)
+ {
+ fdset->fds[fdset->used].events |= POLLIN;
+ }
+ break;
+
+ case STREAM_READ:
+ case STREAM_READ_FIRST:
+ fdset->fds[fdset->used].events |= POLLIN;
+ break;
+
+ case STREAM_WRITE:
+ case STREAM_WRITE_FIRST:
+ case STREAM_CONNECT_BLOCK:
+ fdset->fds[fdset->used].events |= POLLOUT;
+ break;
+
+ case SOCKET_CLOSE:
+ del = sock;
+ break;
+
+ default:
+ break;
+ }
+
+ if (fdset->fds[fdset->used].events)
{
- *highfd = sock->fd;
+ sock->fdsetnr = fdset->used++;
+ }
+ else
+ {
+ sock->fdsetnr = -1;
+ }
+
+ sock = (SLPDSocket*)sock->listitem.next;
+
+ if(del)
+ {
+ SLPDSocketFree((SLPDSocket*)SLPListUnlink(socklist,(SLPListItem*)del));
+ del = 0;
+ }
+ }
+}
+
+#else
+
+/*-------------------------------------------------------------------------*/
+void LoadFdSets(SLPList* socklist,
+ SLPD_fdset *fdset)
+/*-------------------------------------------------------------------------*/
+{
+ SLPDSocket* sock = 0;
+ SLPDSocket* del = 0;
+
+ sock = (SLPDSocket*)socklist->head;
+ while(sock)
+ {
+ if(sock->fd > fdset->highfd)
+ {
+ fdset->highfd = sock->fd;
}
switch(sock->state)
@@ -106,25 +183,25 @@ void LoadFdSets(SLPList* socklist,
case DATAGRAM_UNICAST:
case DATAGRAM_MULTICAST:
case DATAGRAM_BROADCAST:
- FD_SET(sock->fd,readfds);
+ FD_SET(sock->fd,&fdset->readfds);
break;
case SOCKET_LISTEN:
if(socklist->count < SLPD_MAX_SOCKETS)
{
- FD_SET(sock->fd,readfds);
+ FD_SET(sock->fd,&fdset->readfds);
}
break;
case STREAM_READ:
case STREAM_READ_FIRST:
- FD_SET(sock->fd,readfds);
+ FD_SET(sock->fd,&fdset->readfds);
break;
case STREAM_WRITE:
case STREAM_WRITE_FIRST:
case STREAM_CONNECT_BLOCK:
- FD_SET(sock->fd,writefds);
+ FD_SET(sock->fd,&fdset->writefds);
break;
case SOCKET_CLOSE:
@@ -145,17 +222,18 @@ void LoadFdSets(SLPList* socklist,
}
}
+#endif
+
/*------------------------------------------------------------------------*/
void HandleSigTerm()
/*------------------------------------------------------------------------*/
{
struct timeval timeout;
- fd_set readfds;
- fd_set writefds;
- int highfd = 0;
+ SLPD_fdset fdset;
int fdcount = 0;
+ SLPD_fdset_init(&fdset);
SLPDLog("****************************************\n");
SLPDLogTime();
SLPDLog("SLPD daemon shutting down\n");
@@ -179,16 +257,19 @@ void HandleSigTerm()
/* if possible wait until all outgoing socket are done and closed */
while(SLPDOutgoingDeinit(1))
{
- FD_ZERO(&writefds);
- FD_ZERO(&readfds);
- LoadFdSets(&G_OutgoingSocketList, &highfd, &readfds,&writefds);
- fdcount = select(highfd+1,&readfds,&writefds,0,&timeout);
+ SLPD_fdset_reset(&fdset);
+ LoadFdSets(&G_OutgoingSocketList, &fdset);
+#ifdef HAVE_POLL
+ fdcount = poll(fdset.fds, fdset.used, timeout.tv_sec * 1000 + timeout.tv_usec / 1000);
+#else
+ fdcount = select(fdset.highfd+1,&fdset.readfds,&fdset.writefds,0,&timeout);
+#endif
if(fdcount == 0)
{
break;
}
- SLPDOutgoingHandler(&fdcount,&readfds,&writefds);
+ SLPDOutgoingHandler(&fdcount,&fdset);
}
SLPDOutgoingDeinit(0);
@@ -491,11 +572,10 @@ int SetUpSignalHandlers()
int main(int argc, char* argv[])
/*=========================================================================*/
{
- fd_set readfds;
- fd_set writefds;
- int highfd;
+ SLPD_fdset fdset;
int fdcount = 0;
+ SLPD_fdset_init(&fdset);
reg_file_dir = strdup("/etc/slp.reg.d");
#ifdef DEBUG
@@ -616,14 +696,12 @@ int main(int argc, char* argv[])
/*--------------------------------------------------------*/
/* Load the fdsets up with all valid sockets in the list */
/*--------------------------------------------------------*/
- highfd = 0;
- FD_ZERO(&readfds);
- FD_ZERO(&writefds);
- LoadFdSets(&G_IncomingSocketList, &highfd, &readfds,&writefds);
- LoadFdSets(&G_OutgoingSocketList, &highfd, &readfds,&writefds);
+ SLPD_fdset_reset(&fdset);
+ LoadFdSets(&G_IncomingSocketList, &fdset);
+ LoadFdSets(&G_OutgoingSocketList, &fdset);
#ifdef ENABLE_MDNS_SLPD
- LoadFdSets(&G_MDNSSocketList, &highfd, &readfds,&writefds);
+ LoadFdSets(&G_MDNSSocketList, &fdset);
#endif
/*--------------------------------------------------*/
@@ -637,14 +715,18 @@ int main(int argc, char* argv[])
/*-------------*/
/* Main select */
/*-------------*/
- fdcount = select(highfd+1,&readfds,&writefds,0,0);
+#ifdef HAVE_POLL
+ fdcount = poll(fdset.fds, fdset.used, -1);
+#else
+ fdcount = select(fdset.highfd+1,&fdset.readfds,&fdset.writefds,0,0);
+#endif
if(fdcount > 0) /* fdcount will be < 0 when interrupted by a signal */
{
- SLPDIncomingHandler(&fdcount,&readfds,&writefds);
- SLPDOutgoingHandler(&fdcount,&readfds,&writefds);
+ SLPDIncomingHandler(&fdcount,&fdset);
+ SLPDOutgoingHandler(&fdcount,&fdset);
#ifdef ENABLE_MDNS_SLPD
- SLPDMDNSHandler(&fdcount,&readfds,&writefds);
+ SLPDMDNSHandler(&fdcount,&fdset);
#endif
}
--- ./slpd/slpd_mdns.c.orig 2005-08-22 17:24:56.821078934 +0000
+++ ./slpd/slpd_mdns.c 2005-08-22 17:25:15.761391529 +0000
@@ -207,23 +207,20 @@ int SLPDMDNSDeinit()
/*=========================================================================*/
void SLPDMDNSHandler(int* fdcount,
- fd_set* readfds,
- fd_set* writefds)
+ SLPD_fdset* fdset)
/* Handles all outgoing requests that are pending on the specified file */
/* discriptors */
/* */
-/* fdcount (IN/OUT) number of file descriptors marked in fd_sets */
+/* fdcount (IN/OUT) number of file descriptors marked in fdset */
/* */
-/* readfds (IN) file descriptors with pending read IO */
-/* */
-/* writefds (IN) file descriptors with pending read IO */
+/* fdset (IN) file descriptors with pending read/write IO */
/*=========================================================================*/
{
SLPDSocket* sock;
sock = (SLPDSocket*) G_MDNSSocketList.head;
while (sock && *fdcount)
{
- if (FD_ISSET(sock->fd,readfds))
+ if (SLPD_fdset_readok(fdset, sock))
{
switch (sock->state)
{
--- ./slpd/slpd_mdns.h.orig 2005-08-22 17:24:56.821078934 +0000
+++ ./slpd/slpd_mdns.h 2005-08-22 17:25:15.761391529 +0000
@@ -8,6 +8,7 @@
/*=========================================================================*/
#include "slp_linkedlist.h"
#include "slp_mdns.h"
+#include "slpd_socket.h"
/*=========================================================================*/
@@ -17,16 +18,13 @@ extern SLPList G_MDNSSocketList;
/*=========================================================================*/
void SLPDMDNSHandler(int* fdcount,
- fd_set* readfds,
- fd_set* writefds);
+ SLPD_fdset* fdset);
/* Handles all outgoing requests that are pending on the specified file */
/* discriptors */
/* */
-/* fdcount (IN/OUT) number of file descriptors marked in fd_sets */
+/* fdcount (IN/OUT) number of file descriptors marked in fdset */
/* */
-/* readfds (IN) file descriptors with pending read IO */
-/* */
-/* writefds (IN) file descriptors with pending read IO */
+/* fdset (IN) file descriptors with pending read/write IO */
/*=========================================================================*/
--- ./slpd/slpd_outgoing.c.orig 2005-08-22 17:24:56.822078792 +0000
+++ ./slpd/slpd_outgoing.c 2005-08-22 17:25:15.762391388 +0000
@@ -451,24 +451,21 @@ void SLPDOutgoingDatagramWrite(SLPDSocke
/*=========================================================================*/
void SLPDOutgoingHandler(int* fdcount,
- fd_set* readfds,
- fd_set* writefds)
+ SLPD_fdset* fdset)
/* Handles all outgoing requests that are pending on the specified file */
/* discriptors */
/* */
-/* fdcount (IN/OUT) number of file descriptors marked in fd_sets */
+/* fdcount (IN/OUT) number of file descriptors marked in fdset */
/* */
-/* readfds (IN) file descriptors with pending read IO */
-/* */
-/* writefds (IN) file descriptors with pending read IO */
+/* fdset (IN) file descriptors with pending read/write IO */
/*=========================================================================*/
{
SLPDSocket* sock;
sock = (SLPDSocket*)G_OutgoingSocketList.head;
while ( sock && *fdcount )
{
- if ( FD_ISSET(sock->fd,readfds) )
+ if (SLPD_fdset_readok(fdset, sock))
{
switch ( sock->state )
{
@@ -490,7 +487,7 @@ void SLPDOutgoingHandler(int* fdcount,
*fdcount = *fdcount - 1;
}
- else if ( FD_ISSET(sock->fd,writefds) )
+ else if (SLPD_fdset_writeok(fdset, sock))
{
switch ( sock->state )
{
--- ./slpd/slpd_outgoing.h.orig 2005-08-22 17:24:56.823078650 +0000
+++ ./slpd/slpd_outgoing.h 2005-08-22 17:25:15.763391246 +0000
@@ -74,17 +74,14 @@ void SLPDOutgoingAge(time_t seconds);
/*=========================================================================*/
void SLPDOutgoingHandler(int* fdcount,
- fd_set* readfds,
- fd_set* writefds);
+ SLPD_fdset* fdset);
/* Handles all incoming requests that are pending on the specified file */
/* discriptors */
/* */
-/* fdcount (IN/OUT) number of file descriptors marked in fd_sets */
+/* fdcount (IN/OUT) number of file descriptors marked in fdset */
/* */
-/* readfds (IN) file descriptors with pending read IO */
-/* */
-/* writefds (IN) file descriptors with pending read IO */
+/* fdset (IN) file descriptors with pending read/write IO */
/*=========================================================================*/
--- ./slpd/slpd_socket.h.orig 2005-08-22 17:24:56.823078650 +0000
+++ ./slpd/slpd_socket.h 2005-08-22 17:25:15.763391246 +0000
@@ -107,8 +107,50 @@ typedef struct _SLPDSocket
/* Outgoing socket stuff */
int reconns;
SLPList sendlist;
+#ifdef HAVE_POLL
+ int fdsetnr;
+#endif
}SLPDSocket;
+#ifdef HAVE_POLL
+
+#include <sys/poll.h>
+
+typedef struct _SLPD_fdset {
+ struct pollfd *fds;
+ int used;
+ int allocated;
+} SLPD_fdset;
+
+/* the following code supports only one fdset at a time */
+
+#define SLPD_fdset_readok(fdset, sock) ((sock)->fdsetnr != -1 && (sock)->fdsetnr < (fdset)->used && (fdset)->fds[(sock)->fdsetnr].fd == (sock)->fd ? ((fdset)->fds[(sock)->fdsetnr].revents & ((fdset)->fds[(sock)->fdsetnr].events & POLLIN ? (POLLIN|POLLERR|POLLHUP) : POLLIN)) != 0 : 0)
+#define SLPD_fdset_writeok(fdset, sock) ((sock)->fdsetnr != -1 && (sock)->fdsetnr < (fdset)->used && (fdset)->fds[(sock)->fdsetnr].fd == (sock)->fd ? ((fdset)->fds[(sock)->fdsetnr].revents & ((fdset)->fds[(sock)->fdsetnr].events & POLLOUT ? (POLLOUT|POLLERR|POLLHUP) : POLLOUT)) != 0 : 0)
+
+#define SLPD_fdset_reset(fdset) ((fdset)->used = 0)
+#define SLPD_fdset_init(fdset) ((fdset)->used = (fdset)->allocated = 0, (fdset)->fds = 0)
+#define SLPD_fdset_free(fdset) ((fdset)->allocated && xfree((fdset)->fds), SLPD_fdset_init(fdset))
+
+#else
+
+typedef struct _SLPD_fdset {
+ fd_set readfds;
+ fd_set writefds;
+ int highfd;
+} SLPD_fdset;
+
+#define SLPD_fdset_readok(fdset, sock) (FD_ISSET((sock)->fd, &(fdset)->readfds))
+#define SLPD_fdset_writeok(fdset, sock) (FD_ISSET((sock)->fd, &(fdset)->writefds))
+
+#define SLPD_fdset_reset(fdset) do { \
+ FD_ZERO(&(fdset)->readfds); \
+ FD_ZERO(&(fdset)->writefds); \
+ (fdset)->highfd = 0; \
+ } while(0)
+#define SLPD_fdset_init(fdset)
+#define SLPD_fdset_free(fdset)
+
+#endif
/*==========================================================================*/
SLPDSocket* SLPDSocketCreateConnected(struct in_addr* addr);
--- ./slpd/slpd_win32.c.orig 2005-08-22 17:24:56.824078508 +0000
+++ ./slpd/slpd_win32.c 2005-08-22 17:25:15.764391104 +0000
@@ -81,9 +81,7 @@ extern int G_SIGTERM;
/*-------------------------------------------------------------------------*/
void LoadFdSets(SLPList* socklist,
- int* highfd,
- fd_set* readfds,
- fd_set* writefds);
+ SLPD_fdset *fdset);
/* see slpd_main.c */
/*-------------------------------------------------------------------------*/
@@ -221,16 +219,18 @@ void ServiceStop()
void ServiceStart (int argc, char **argv)
/*--------------------------------------------------------------------------*/
{
- fd_set readfds;
- fd_set writefds;
- int highfd;
+ SLPD_fdset fdset;
int fdcount = 0;
time_t curtime;
time_t alarmtime;
+#ifndef HAVE_POLL
struct timeval timeout;
+#endif
WSADATA wsaData;
WORD wVersionRequested = MAKEWORD(1,1);
+ SLPD_fdset_init(&fdset);
+
/*------------------------*/
/* Service initialization */
/*------------------------*/
@@ -335,11 +335,9 @@ void ServiceStart (int argc, char **argv
/*--------------------------------------------------------*/
/* Load the fdsets up with all valid sockets in the list */
/*--------------------------------------------------------*/
- highfd = 0;
- FD_ZERO(&readfds);
- FD_ZERO(&writefds);
- LoadFdSets(&G_IncomingSocketList, &highfd, &readfds,&writefds);
- LoadFdSets(&G_OutgoingSocketList, &highfd, &readfds,&writefds);
+ SLPD_fdset_reset(&fdset);
+ LoadFdSets(&G_IncomingSocketList, &fdset);
+ LoadFdSets(&G_OutgoingSocketList, &fdset);
/*--------------------------------------------------*/
/* Before select(), check to see if we got a signal */
@@ -352,13 +350,17 @@ void ServiceStart (int argc, char **argv
/*-------------*/
/* Main select */
/*-------------*/
+#ifdef HAVE_POLL
+ fdcount = poll(fdset.fds, fdset.used, SLPD_AGE_INTERVAL * 1000);
+#else
timeout.tv_sec = SLPD_AGE_INTERVAL;
timeout.tv_usec = 0;
- fdcount = select(highfd+1,&readfds,&writefds,0,&timeout);
+ fdcount = select(fdset.highfd+1,&fdset.readfds,&fdset.writefds,0,&timeout);
+#endif
if(fdcount > 0) /* fdcount will be < 0 when timed out */
{
- SLPDIncomingHandler(&fdcount,&readfds,&writefds);
- SLPDOutgoingHandler(&fdcount,&readfds,&writefds);
+ SLPDIncomingHandler(&fdcount,&fdset);
+ SLPDOutgoingHandler(&fdcount,&fdset);
}
/*----------------*/

385
openslp.spec Normal file
View File

@ -0,0 +1,385 @@
#
# spec file for package openslp (Version 1.2.0)
#
# Copyright (c) 2006 SUSE LINUX Products GmbH, Nuernberg, Germany.
# This file and all modifications and additions to the pristine
# package are under the same license as the package itself.
#
# Please submit bugfixes or comments via http://bugs.opensuse.org/
#
# norootforbuild
Name: openslp
BuildRequires: openssl-devel
Summary: An OpenSLP Implementation of Service Location Protocol V2
Version: 1.2.0
Release: 43
License: BSD License and BSD-like, Other License(s), see package
Group: System/Daemons
URL: http://www.openslp.org/
PreReq: %fillup_prereq %insserv_prereq
BuildRoot: %{_tmppath}/%{name}-%{version}-build
Source0: %name-%version.tar.bz2
Source1: slpd.init
Source2: README.SuSE
Source3: openslp.desktop
Source4: openslp-devel.desktop
Source5: openslp.logrotate
Patch1: openslp.diff
Patch2: openslp.audit.diff
Patch3: extensions.diff
Patch4: slptool-timeout.diff
Patch5: hppa.diff
Patch6: v1dadiscovery.diff
Patch7: openslp.poll.diff
Patch8: openslp.v1sladdr.diff
Patch9: openslp.tcpclearovr.diff
Patch10: openslp.checkovr.diff
Patch11: openslp.truncate.diff
Patch12: openslp.emptyanswer.diff
Patch13: openslp.doubleequal.diff
%description
Service Location Protocol is an IETF standards track protocol that
provides a framework that allows networking applications to discover
the existence, location, and configuration of networked services in
enterprise networks.
OpenSLP is an open source implementation of the SLPv2 protocol as
defined by RFC 2608 and RFC 2614. This package includes the slptool
and runtime libraries.
Authors:
--------
Matthew Peterson <mpeterson@calderasystems.com>
Ganesan Rajagopal <rganesan@myrealbox.com>
David McCormack <david.mccormack@ottawa.com>
Evan Hughes <hughes@lab43.org>
Matthieu Desmons <mdes@ocegr.fr>
Praveen Kumar Amritaluru <praveen@india.hp.com>
%package server
Group: System/Daemons
Summary: The OpenSLP Implementation of the Service Location Protocol V2
%description server
Service Location Protocol is an IETF standards track protocol that
provides a framework that allows networking applications to discover
the existence, location, and configuration of networked services in
enterprise networks.
This package contains the SLP server. Every system, which provides any
services that should be used via an SLP client must run this server and
register the service.
Authors:
--------
Matthew Peterson <mpeterson@calderasystems.com>
Ganesan Rajagopal <rganesan@myrealbox.com>
David McCormack <david.mccormack@ottawa.com>
Evan Hughes <hughes@lab43.org>
Matthieu Desmons <mdes@ocegr.fr>
Praveen Kumar Amritaluru <praveen@india.hp.com>
%package devel
Requires: openssl-devel openslp = %version
Group: System/Daemons
Summary: OpenSLP Development SDK
%description devel
Service Location Protocol is an IETF standards track protocol that
provides a framework that allows networking applications to discover
the existence, location, and configuration of networked services in
enterprise networks.
This package contains header and library files to compile applications
with SLP support. It also contains developer documentation to develop
such applications.
Authors:
--------
Matthew Peterson <mpeterson@calderasystems.com>
Ganesan Rajagopal <rganesan@myrealbox.com>
David McCormack <david.mccormack@ottawa.com>
Evan Hughes <hughes@lab43.org>
Matthieu Desmons <mdes@ocegr.fr>
Praveen Kumar Amritaluru <praveen@india.hp.com>
%prep
%setup -q
%patch1
%patch2
%patch3
%patch4
%ifarch hppa
%patch5
%endif
%patch6
%patch7
%patch8
%patch9
%patch10
%patch11
%patch12
%patch13
autoreconf --force --install
%build
export CFLAGS="$RPM_OPT_FLAGS -fstack-protector"
./configure \
--prefix=/usr \
--libdir=%_libdir \
--sysconfdir=%_sysconfdir \
--enable-slpv1 \
--enable-async-api \
--enable-slpv2-security
make
%install
rm -rf ${RPM_BUILD_ROOT}
mkdir -p ${RPM_BUILD_ROOT}/etc/slp.reg.d
cp etc/slp.conf ${RPM_BUILD_ROOT}/etc
cp etc/slp.reg ${RPM_BUILD_ROOT}/etc
cp etc/slp.spi ${RPM_BUILD_ROOT}/etc
mkdir -p ${RPM_BUILD_ROOT}/%_libdir
libtool install libslp/libslp.la ${RPM_BUILD_ROOT}/%_libdir
mkdir -p ${RPM_BUILD_ROOT}/usr/sbin
libtool install slpd/slpd ${RPM_BUILD_ROOT}/usr/sbin
mkdir -p ${RPM_BUILD_ROOT}/usr/bin
libtool install slptool/slptool ${RPM_BUILD_ROOT}/usr/bin
mkdir -p ${RPM_BUILD_ROOT}/usr/include
cp libslp/slp.h ${RPM_BUILD_ROOT}/usr/include
mkdir -p ${RPM_BUILD_ROOT}%_defaultdocdir/%name
find . -name CVS -o -name .cvsignore -o -name .xvpics | xargs rm -rf
cp -a AUTHORS COPYING README FAQ doc/rfc doc/html %SOURCE2 \
${RPM_BUILD_ROOT}%_defaultdocdir/%name
mkdir -p ${RPM_BUILD_ROOT}/etc/init.d/
install -m 755 %{SOURCE1} ${RPM_BUILD_ROOT}/etc/init.d/slpd
ln -sf ../../etc/init.d/slpd ${RPM_BUILD_ROOT}/usr/sbin/rcslpd
ln -sf ../../etc/init.d/slpd ${RPM_BUILD_ROOT}/usr/sbin/rcopenslp
install -D -m 0644 %{SOURCE5} ${RPM_BUILD_ROOT}/etc/logrotate.d/openslp-server
# install susehelp file
mkdir -p $RPM_BUILD_ROOT/usr/share/susehelp/meta/Administration/
install -m 0644 %SOURCE3 \
$RPM_BUILD_ROOT/usr/share/susehelp/meta/Administration/
mkdir -p $RPM_BUILD_ROOT/usr/share/susehelp/meta/Development/Libraries/
install -m 0644 %SOURCE4 \
$RPM_BUILD_ROOT/usr/share/susehelp/meta/Development/Libraries/
%if 0
# actually, these files should get translated, but do we really want to
# add update-desktop-files to needed_for_build ?
%suse_update_desktop_file $RPM_BUILD_ROOT/usr/share/susehelp/meta/Administration/openslp.desktop
%suse_update_desktop_file $RPM_BUILD_ROOT/usr/share/susehelp/meta/Development/Libraries/openslp-devel.desktop
%endif
%post
%run_ldconfig
%postun
%run_ldconfig
%post server
%if %sles_version > 0
%{fillup_and_insserv -y slpd}
%else
%{fillup_and_insserv slpd}
%endif
%postun server
%restart_on_update slpd
%insserv_cleanup
%preun server
%stop_on_removal slpd
%clean
rm -rf $RPM_BUILD_ROOT
%files
%defattr(-,root,root)
%dir %_defaultdocdir/%name
%dir %_defaultdocdir/%name/html
%doc %_defaultdocdir/%name/AUTHORS
%doc %_defaultdocdir/%name/COPYING
%doc %_defaultdocdir/%name/README
%doc %_defaultdocdir/%name/README.SuSE
%_libdir/libslp.so.*
/usr/bin/slptool
%config(noreplace) /etc/slp.conf
%config(noreplace) /etc/slp.spi
%files server
%defattr(-,root,root)
%dir /usr/share/susehelp
%dir /usr/share/susehelp/meta
%dir /usr/share/susehelp/meta/Administration
%doc %dir %_defaultdocdir/%name/FAQ
%doc %_defaultdocdir/%name/html/IntroductionToSLP
%doc %_defaultdocdir/%name/html/UsersGuide
%doc %_defaultdocdir/%name/html/faq.html
%doc %_defaultdocdir/%name/rfc
%doc /usr/share/susehelp/meta/Administration/openslp.desktop
%dir /etc/slp.reg.d/
/usr/sbin/rcopenslp
/usr/sbin/rcslpd
/usr/sbin/slpd
/etc/init.d/slpd
%config(noreplace) /etc/slp.reg
%config(noreplace) /etc/logrotate.d/openslp-server
%files devel
%defattr(-,root,root)
%dir /usr/share/susehelp
%dir /usr/share/susehelp/meta
%dir /usr/share/susehelp/meta/Development
%dir /usr/share/susehelp/meta/Development/Libraries
%doc %_defaultdocdir/%name/html/ProgrammersGuide
%doc /usr/share/susehelp/meta/Development/Libraries/openslp-devel.desktop
/usr/include/slp.h
%_libdir/libslp.a
%_libdir/libslp.la
%_libdir/libslp.so
%changelog -n openslp
* Thu Nov 16 2006 - mls@suse.de
- truncate oversized udp messages, finally fixes [#185483]
(can be turned of with "net.slp.oversizedUDP" option)
- do not try to send back empty answers
- add option "net.slp.allowDoubleEqualInPredicate" to make openslp
work with some buggy clients that use "==" for comparison [#95043]
- changed SLPGetPeer interface to support IPv6
* Tue Sep 12 2006 - mls@suse.de
- obey OVERFLOW bit of incoming udp messages [#185483]
- use right length in send() calls [#185483]
- fix errno check in IncomingStreamWrite
- add SLPGetPeer method in libslp
- add --peerinfo option to slptool to print peerinfo
* Wed May 10 2006 - mls@suse.de
- fix unaligned memory access on ia64 [#171932]
* Fri Mar 24 2006 - mls@suse.de
- fix listening on multiple interfaces [#160008]
* Sat Mar 18 2006 - schwab@suse.de
- Fix file descritor leak [#159303].
* Mon Jan 30 2006 - mls@suse.de
- fix bug in DropSLPMulticastGroup
- add -fstack-protector to CFLAGS
- added logrotate script [#143069]
* Wed Jan 25 2006 - mls@suse.de
- converted neededforbuild to BuildRequires
* Fri Dec 23 2005 - mls@suse.de
- clear overflow bit on TCP connections [#135248]
* Thu Sep 29 2005 - dmueller@suse.de
- add norootforbuild
* Mon Aug 22 2005 - mls@suse.de
- also listen on SLPv1 General Multicast address [#64138]
- use poll instead of select [#65673]
* Tue Feb 15 2005 - mls@suse.de
- update to version 1.2.0
- fixed security audit findings
- disable mdns in slpd for now, libslp still supports it
* Fri Dec 03 2004 - mls@suse.de
- fix slpv DA discovery scope handling (#48728)
- use _dns-sd instead of _mdns in mdns findsrvtypes query (#48325)
* Thu Oct 14 2004 - adrian@suse.de
- add meta information for suse help.
* Sun Jun 13 2004 - bg@suse.de
- reduce hardcoded optimization from -O3 to -O2 to circumvent
ICE on hppa
* Tue Jun 01 2004 - mls@suse.de
- added fillup and insserv prereq
* Thu May 27 2004 - mls@suse.de
- use /proc/net/tcp_listen and /proc/net/tcp6_listen if
available to keep things fast on systems with lots of
network connections [#40888]
* Wed May 05 2004 - mls@suse.de
- treat empty attributes as illegal [#39669]
- always start slpd on SLES [#39863]
* Fri Apr 23 2004 - mls@suse.de
- libslp: use configured TTL settings [#39030]
* Fri Apr 02 2004 - mls@suse.de
- beta is over, don't always start slpd
* Fri Apr 02 2004 - kukuk@suse.de
- Fix init script
* Wed Mar 31 2004 - mls@suse.de
- fix sighup processing
- clean up spi code
- fix spi null pointer reference
- fix namingauth comparison
- added try-restart to rcslpd
- fix slp.conf re-read
- fix prlist buffer overrun
* Mon Mar 29 2004 - mls@suse.de
- turn around srvtypes order in mdns
* Thu Mar 18 2004 - mls@suse.de
- code cleanup
- provide A RR with SRV RRs
- don't pack .xvpics
* Fri Mar 12 2004 - mls@suse.de
- added missing SLPGetMDNSName prototype to slp.h
* Fri Mar 12 2004 - mls@suse.de
- slpd: fix hostname detection segfault
- slpd: use ttl 255 for mdns
- slpd: put attrs in mdns TXT RR
- libslp: check mdns ttl
- libslp: make getattr work with mdns
- libslp: make mdns name available via new SLPGetMDNSName() function
* Thu Mar 04 2004 - mls@suse.de
- libslp: add scope/nameingauth/predicate to query
- slpd: reply to mdns service requests
- slpd: don't play DA if our hostname expands to loopback
- slpd: fix null pointer reference if SrvReg request is sent
over tcp (as done by apple)
* Fri Feb 27 2004 - mls@suse.de
- slpd: check port status every 15 seconds for watch-port-tcp/udp
entries
- libslp: send MDNS queries for scope _mdns
* Sun Feb 15 2004 - adrian@suse.de
- export full qualified hostnames for $HOSTNAME
- replace several $HOSTNAME tags in a srvurl
- do only accept .reg files (no .rpmsave for instance)
* Sat Feb 14 2004 - adrian@suse.de
- fix /proc/net/tcp* parsing
- ONLY FOR BETA: start slpd always
* Thu Jan 29 2004 - adrian@suse.de
- fix reading from slpd.reg.d directory
(was broken since chroot run)
* Wed Jan 14 2004 - adrian@suse.de
- slptool register now services with max timeout.
* Tue Dec 16 2003 - adrian@suse.de
- fix sig11 when using the library without spi file
* Mon Dec 08 2003 - adrian@suse.de
- security enhancements:
* use chroot and open needed file descriptors before
* panic if chroot or setuid fails
* pid-file= option in reg files is useless now, so
tcp-port= must be used for this now
- add SSL support again
* Wed Nov 26 2003 - adrian@suse.de
- add buffer fix from cvs
- add README.SuSE with config howto
* Thu Nov 20 2003 - adrian@suse.de
- drop the multicast route creation in runlevel script.
we do not need it anymore with 1.1.5
* Wed Nov 19 2003 - adrian@suse.de
- update to version 1.1.5
* development version, but it contains lots of fixes
- use $HOSTNAME instead of $LOCALHOST in reg files
* Fri Nov 14 2003 - adrian@suse.de
- use correct keyword "X-UnitedLinux-Should-Start" in init script
(seen by Martin Vidner)
* Thu Nov 13 2003 - adrian@suse.de
- add "tcp-port=" option to test services running via (x)inted
- start after (x)inetd
* Wed Nov 12 2003 - adrian@suse.de
- add code to parse .reg files from any package below /etc/slp.reg.d/
* Sun Nov 09 2003 - adrian@suse.de
- fix security issue in init script
* Sat Nov 08 2003 - adrian@suse.de
- initial package of version 1.0.11

27
openslp.tcpclearovr.diff Normal file
View File

@ -0,0 +1,27 @@
--- ./slpd/slpd_incoming.c.orig 2005-12-23 14:13:55.000000000 +0000
+++ ./slpd/slpd_incoming.c 2005-12-23 14:42:26.000000000 +0000
@@ -63,6 +63,7 @@
/*=========================================================================*/
#include "slp_xmalloc.h"
#include "slp_message.h"
+#include "slp_v1message.h"
/*=========================================================================*/
@@ -242,6 +243,16 @@ void IncomingStreamRead(SLPList* socklis
sock->state = SOCKET_CLOSE;
break;
default:
+ /* some clients cannot cope with the OVERFLOW
+ * bit set on a TCP stream, so always clear it
+ */
+ if (sock->sendbuf && sock->sendbuf->end - sock->sendbuf->start > 5)
+ {
+ if (sock->sendbuf->start[0] == 1)
+ sock->sendbuf->start[4] &= ~SLPv1_FLAG_OVERFLOW;
+ else
+ sock->sendbuf->start[5] &= ~(SLP_FLAG_OVERFLOW >> 8);
+ }
sock->state = STREAM_WRITE_FIRST;
IncomingStreamWrite(socklist, sock);
}

188
openslp.truncate.diff Normal file
View File

@ -0,0 +1,188 @@
--- ./slpd/slpd_incoming.c.orig 2006-11-14 16:25:18.000000000 +0000
+++ ./slpd/slpd_incoming.c 2006-11-15 18:20:10.000000000 +0000
@@ -79,6 +79,7 @@ void IncomingDatagramRead(SLPList* sockl
int bytestowrite;
int byteswritten;
int peeraddrlen = sizeof(struct sockaddr_in);
+ int truncate;
bytesread = recvfrom(sock->fd,
sock->recvbuf->start,
@@ -90,9 +91,13 @@ void IncomingDatagramRead(SLPList* sockl
{
sock->recvbuf->end = sock->recvbuf->start + bytesread;
+ truncate = SLP_MAX_DATAGRAM_SIZE;
+ if (G_SlpdProperty.oversizedUDP)
+ truncate = 0;
switch (SLPDProcessMessage(&sock->peeraddr,
sock->recvbuf,
- &(sock->sendbuf)))
+ &(sock->sendbuf),
+ truncate))
{
case SLP_ERROR_PARSE_ERROR:
case SLP_ERROR_VER_NOT_SUPPORTED:
@@ -238,7 +243,7 @@ void IncomingStreamRead(SLPList* socklis
{
switch (SLPDProcessMessage(&sock->peeraddr,
sock->recvbuf,
- &(sock->sendbuf)))
+ &(sock->sendbuf), 0))
{
case SLP_ERROR_PARSE_ERROR:
case SLP_ERROR_VER_NOT_SUPPORTED:
--- ./slpd/slpd_outgoing.c.orig 2006-11-14 16:26:13.000000000 +0000
+++ ./slpd/slpd_outgoing.c 2006-11-15 18:29:31.000000000 +0000
@@ -89,7 +89,7 @@ void OutgoingDatagramRead(SLPList* sockl
SLPDProcessMessage(&(sock->peeraddr),
sock->recvbuf,
- &(sock->sendbuf));
+ &(sock->sendbuf), 0);
/* Completely ignore the message */
}
@@ -264,7 +264,7 @@ void OutgoingStreamRead(SLPList* socklis
{
switch ( SLPDProcessMessage(&(sock->peeraddr),
sock->recvbuf,
- &(sock->sendbuf)) )
+ &(sock->sendbuf), 0) )
{
case SLP_ERROR_DA_BUSY_NOW:
sock->state = STREAM_WRITE_WAIT;
--- ./slpd/slpd_process.c.orig 2006-11-14 16:18:24.000000000 +0000
+++ ./slpd/slpd_process.c 2006-11-15 15:22:05.000000000 +0000
@@ -301,7 +301,8 @@ int ProcessDASrvRqst(SLPMessage message,
/*-------------------------------------------------------------------------*/
int ProcessSrvRqst(SLPMessage message,
SLPBuffer* sendbuf,
- int errorcode)
+ int errorcode,
+ int truncate)
/*-------------------------------------------------------------------------*/
{
int i;
@@ -310,12 +311,6 @@ int ProcessSrvRqst(SLPMessage message,
int size = 0;
SLPBuffer result = *sendbuf;
-#ifdef ENABLE_SLPv2_SECURITY
- SLPAuthBlock* authblock = 0;
- int j;
-#endif
-
-
/*--------------------------------------------------------------*/
/* If errorcode is set, we can not be sure that message is good */
/* Go directly to send response code */
@@ -445,33 +440,24 @@ int ProcessSrvRqst(SLPMessage message,
{
for (i=0;i<db->urlcount;i++)
{
+ /* check size limitation */
+ if (truncate && size > truncate)
+ break;
+
/* urlentry is the url from the db result */
urlentry = db->urlarray[i];
- size += urlentry->urllen + 6; /* 1 byte for reserved */
- /* 2 bytes for lifetime */
- /* 2 bytes for urllen */
- /* 1 byte for authcount */
-#ifdef ENABLE_SLPv2_SECURITY
-
- /* make room to include the authblock that was asked for */
- if (G_SlpdProperty.securityEnabled &&
- message->body.srvrqst.spistrlen )
+ if (urlentry->opaque == 0)
{
- for (j=0; j<urlentry->authcount;j++)
- {
- if (SLPCompareString(urlentry->autharray[j].spistrlen,
- urlentry->autharray[j].spistr,
- message->body.srvrqst.spistrlen,
- message->body.srvrqst.spistr) == 0)
- {
- authblock = &(urlentry->autharray[j]);
- size += authblock->length;
- break;
- }
- }
+ size += urlentry->urllen + 6; /* 1 byte for reserved */
+ /* 2 bytes for lifetime */
+ /* 2 bytes for urllen */
+ /* 1 byte for authcount */
+ }
+ else
+ {
+ size += urlentry->opaquelen;
}
-#endif
}
}
@@ -523,6 +509,10 @@ int ProcessSrvRqst(SLPMessage message,
for (i=0;i<db->urlcount;i++)
{
+ /* check size limitation */
+ if (truncate && result->curpos - result->start > truncate)
+ break;
+
/* urlentry is the url from the db result */
urlentry = db->urlarray[i];
@@ -1312,7 +1302,8 @@ int ProcessSAAdvert(SLPMessage message,
/*=========================================================================*/
int SLPDProcessMessage(struct sockaddr_in* peerinfo,
SLPBuffer recvbuf,
- SLPBuffer* sendbuf)
+ SLPBuffer* sendbuf,
+ int truncate)
/* Processes the recvbuf and places the results in sendbuf */
/* */
/* peerinfo - the socket the message was received on */
@@ -1390,7 +1381,7 @@ int SLPDProcessMessage(struct sockaddr_i
switch (message->header.functionid)
{
case SLP_FUNCT_SRVRQST:
- errorcode = ProcessSrvRqst(message,sendbuf,errorcode);
+ errorcode = ProcessSrvRqst(message,sendbuf,errorcode,truncate);
break;
case SLP_FUNCT_SRVREG:
--- ./slpd/slpd_process.h.orig 2006-11-14 16:23:21.000000000 +0000
+++ ./slpd/slpd_process.h 2006-11-14 16:23:38.000000000 +0000
@@ -60,7 +60,8 @@
/*=========================================================================*/
int SLPDProcessMessage(struct sockaddr_in* peerinfo,
SLPBuffer recvbuf,
- SLPBuffer* sendbuf) ;
+ SLPBuffer* sendbuf,
+ int truncate) ;
/* Processes the recvbuf and places the results in sendbuf */
/* */
/* peerinfo - the socket the message was received on */
--- ./slpd/slpd_property.c.orig 2006-11-15 18:14:47.000000000 +0000
+++ ./slpd/slpd_property.c 2006-11-15 18:16:28.000000000 +0000
@@ -131,6 +131,7 @@ int SLPDPropertyInit(const char* conffil
G_SlpdProperty.securityEnabled = SLPPropertyAsBoolean(SLPPropertyGet("net.slp.securityEnabled"));
G_SlpdProperty.checkSourceAddr = SLPPropertyAsBoolean(SLPPropertyGet("net.slp.checkSourceAddr"));
G_SlpdProperty.DAHeartBeat = SLPPropertyAsInteger(SLPPropertyGet("net.slp.DAHeartBeat"));
+ G_SlpdProperty.oversizedUDP = SLPPropertyAsBoolean(SLPPropertyGet("net.slp.oversizedUDP"));
/*-------------------------------------*/
--- ./slpd/slpd_property.h.orig 2006-11-15 18:14:05.000000000 +0000
+++ ./slpd/slpd_property.h 2006-11-15 18:15:28.000000000 +0000
@@ -94,6 +94,7 @@ typedef struct _SLPDProperty
int securityEnabled;
int checkSourceAddr;
int DAHeartBeat;
+ int oversizedUDP;
}SLPDProperty;

34
openslp.v1sladdr.diff Normal file
View File

@ -0,0 +1,34 @@
--- ./common/slp_message.h.orig 2005-04-13 17:21:37.000000000 +0000
+++ ./common/slp_message.h 2005-04-13 17:22:47.527724927 +0000
@@ -93,6 +93,7 @@
#define SLP_RESERVED_PORT 427
#define SLP_MCAST_ADDRESS 0xeffffffd /* 239.255.255.253 */
#define SLP_BCAST_ADDRESS 0xffffffff /* 255.255.255.255 */
+#define SLPv1_SL_MCAST_ADDRESS 0xe0000116 /* 224.0.1.22 */
#define SLPv1_DA_MCAST_ADDRESS 0xe0000123 /* 224.0.1.35 */
#define LOOPBACK_ADDRESS 0x7f000001 /* 127.0.0.1 */
#define SLP_MAX_DATAGRAM_SIZE 1400
--- ./slpd/slpd_incoming.c.orig 2005-04-13 15:58:18.000000000 +0000
+++ ./slpd/slpd_incoming.c 2005-04-13 17:29:26.486900643 +0000
@@ -534,6 +531,21 @@
}
#if defined(ENABLE_SLPv1)
+ /*------------------------------------------------------------*/
+ /* Create socket that will handle multicast UDP for SLPv1 */
+ /* Service Location General Multicast address. */
+ /*------------------------------------------------------------*/
+ mcastaddr.s_addr = htonl(SLPv1_SL_MCAST_ADDRESS);
+ sock = SLPDSocketCreateBoundDatagram(&myaddr,
+ &mcastaddr,
+ DATAGRAM_MULTICAST);
+ if (sock)
+ {
+ SLPListLinkTail(&G_IncomingSocketList,(SLPListItem*)sock);
+ SLPDLog("SLPv1 Service Location General Multicast socket on %s ready\n",
+ inet_ntoa(myaddr));
+ }
+
if (G_SlpdProperty.isDA)
{
/*------------------------------------------------------------*/

0
ready Normal file
View File

72
slpd.init Normal file
View File

@ -0,0 +1,72 @@
#! /bin/sh
# Copyright (c) 2003 SuSE AG Nuernberg, Germany.
#
# Author: adrian@suse.de, based on template from source package
#
# /etc/init.d/slpd
# and its symbolic link
# /usr/sbin/rcslpd
#
### BEGIN INIT INFO
# Provides: openslp slpd
# Required-Start: $network $named
# Required-Stop:
# Default-Start: 3 5
# Default-Stop: 0 1 2 4 6
# Description: slpd - OpenSLP daemon for the Service Location Protocol
### END INIT INFO
. /etc/rc.status
# Determine the base and follow a runlevel link name.
base=${0##*/}
link=${base#*[SK][0-9][0-9]}
# Force execution if not called by a runlevel directory.
test -x /usr/sbin/slpd || exit 0
case "$1" in
start)
echo -n 'Starting slpd '
startproc /usr/sbin/slpd
rc_status -v
;;
stop)
echo -n "Shutting down slpd "
killproc -TERM /usr/sbin/slpd
rc_status -v
;;
restart)
$0 stop
$0 start
rc_status
;;
try-restart)
$0 status
if test $? = 0; then
$0 restart
else
rc_reset
fi
rc_status
;;
force-reload)
$0 stop; sleep 1 && $0 start
rc_status
;;
reload)
echo -n "Reload service slpd "
killproc -HUP /usr/sbin/slpd
rc_status -v
;;
status)
echo -n "Checking for slpd "
checkproc /usr/sbin/slpd
rc_status -v
;;
*)
echo "Usage: $0 {start|stop|try-restart|restart|force-reload|reload|status}"
exit 1
esac
rc_exit

11
slptool-timeout.diff Normal file
View File

@ -0,0 +1,11 @@
--- slptool/slptool.c
+++ slptool/slptool.c 2004/01/14 12:26:12
@@ -481,7 +481,7 @@
result = SLPReg(hslp,
cmdline->cmdparam1,
- SLP_LIFETIME_DEFAULT,
+ SLP_LIFETIME_MAXIMUM,
srvtype,
cmdline->cmdparam2,
SLP_TRUE,

67
v1dadiscovery.diff Normal file
View File

@ -0,0 +1,67 @@
--- ./common/slp_v1message.c.orig 2002-12-03 21:04:50.000000000 +0000
+++ ./common/slp_v1message.c 2004-12-03 18:48:44.740573934 +0000
@@ -40,6 +40,7 @@
#include "slp_v1message.h"
#include "slp_utf8.h"
+#include "slp_compare.h"
/* Implementation Note:
*
@@ -215,7 +216,8 @@
srvrqst->predicate += srvrqst->srvtypelen + 1;
/* Now split out the scope (if any) */
- if(*srvrqst->predicate == '/')
+ /* Special case DA discovery, empty scope is allowed here */
+ if(*srvrqst->predicate == '/' && SLPCompareString(srvrqst->srvtypelen, srvrqst->srvtype, 15, "directory-agent") != 0)
{
/* no scope - so set default scope */
srvrqst->scopelist = "default";
--- ./slpd/slpd_v1process.c.orig 2004-12-03 18:49:08.656163167 +0000
+++ ./slpd/slpd_v1process.c 2004-12-03 19:10:09.159293506 +0000
@@ -76,25 +76,32 @@
int errorcode)
/*-------------------------------------------------------------------------*/
{
- if (message->body.srvrqst.scopelistlen == 0 ||
- SLPIntersectStringList(message->body.srvrqst.scopelistlen,
- message->body.srvrqst.scopelist,
- G_SlpdProperty.useScopesLen,
- G_SlpdProperty.useScopes))
+ if (G_SlpdProperty.isDA)
{
- /* fill out real structure */
- errorcode = SLPDKnownDAGenerateMyV1DAAdvert(errorcode,
- message->header.encoding,
- message->header.xid,
- sendbuf);
+ if (message->body.srvrqst.scopelistlen == 0 ||
+ SLPIntersectStringList(message->body.srvrqst.scopelistlen,
+ message->body.srvrqst.scopelist,
+ G_SlpdProperty.useScopesLen,
+ G_SlpdProperty.useScopes))
+ {
+ /* fill out real structure */
+ errorcode = SLPDKnownDAGenerateMyV1DAAdvert(errorcode,
+ message->header.encoding,
+ message->header.xid,
+ sendbuf);
+ }
+ else
+ {
+ errorcode = SLP_ERROR_SCOPE_NOT_SUPPORTED;
+ }
}
else
{
- errorcode = SLP_ERROR_SCOPE_NOT_SUPPORTED;
+ errorcode = SLP_ERROR_MESSAGE_NOT_SUPPORTED;
}
/* don't return errorcodes to multicast messages */
- if (errorcode == 0)
+ if (errorcode != 0)
{
if (message->header.flags & SLP_FLAG_MCAST ||
ISMCAST(peeraddr->sin_addr))