Accepting request 223216 from network:utilities
-> OBS-URL: https://build.opensuse.org/request/show/223216 OBS-URL: https://build.opensuse.org/package/show/openSUSE:Factory/openslp?expand=0&rev=38
This commit is contained in:
commit
febf7f0fe9
@ -1,5 +1,5 @@
|
||||
#
|
||||
# Service Location Protocol on SuSE
|
||||
# Service Location Protocol on SUSE
|
||||
#
|
||||
|
||||
The Service Location Protcol (SLP) is part of the zerconf concept to provide
|
4182
extensions.diff
4182
extensions.diff
File diff suppressed because it is too large
Load Diff
11
hppa.diff
11
hppa.diff
@ -1,11 +0,0 @@
|
||||
--- 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
|
@ -1,13 +0,0 @@
|
||||
Index: openslp-1.2.0/slpd/slpd_main.c
|
||||
===================================================================
|
||||
--- openslp-1.2.0.orig/slpd/slpd_main.c
|
||||
+++ openslp-1.2.0/slpd/slpd_main.c
|
||||
@@ -508,7 +508,7 @@ int Daemonize(const char* pidfile)
|
||||
close(2);
|
||||
setsid(); /* will only fail if we are already the process group leader */
|
||||
|
||||
- pwent = getpwnam("daemon");
|
||||
+ pwent = getpwnam("openslp");
|
||||
/*---------------------*/
|
||||
/* chroot to slp.reg.d */
|
||||
/*---------------------*/
|
@ -1,3 +0,0 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:450b0f6153965412c358ecebfce68ae26fbdfb9cc3a3653a16458048948929ea
|
||||
size 548410
|
BIN
openslp-2.0.0.tar.gz
(Stored with Git LFS)
Normal file
BIN
openslp-2.0.0.tar.gz
(Stored with Git LFS)
Normal file
Binary file not shown.
@ -1,336 +0,0 @@
|
||||
--- slpd/slpd_main.c.orig
|
||||
+++ slpd/slpd_main.c
|
||||
@@ -93,7 +93,7 @@ static void SLPDOpenDABackupFile()
|
||||
char filename[1024];
|
||||
snprintf(filename, sizeof(filename), "%s/slpd/%s", reg_file_dir, "DABackup");
|
||||
|
||||
- fp = fopen(filename, "a+");
|
||||
+ fp = fopen(filename, "a+e");
|
||||
if (!DABackupfp && !fp)
|
||||
SLPDLog("Could not open DABackup file\n");
|
||||
if (fp)
|
||||
--- slpd/slpd_outgoing.c.orig
|
||||
+++ slpd/slpd_outgoing.c
|
||||
@@ -142,7 +142,7 @@ void OutgoingStreamReconnect(SLPList* so
|
||||
/* socket */
|
||||
/*----------------------------------------------------------------*/
|
||||
CloseSocket(sock->fd);
|
||||
- sock->fd = socket(PF_INET,SOCK_STREAM,0);
|
||||
+ sock->fd = socket(PF_INET,SOCK_STREAM|SOCK_CLOEXEC,0);
|
||||
if ( sock->fd < 0 )
|
||||
{
|
||||
sock->state = SOCKET_CLOSE;
|
||||
--- slpd/slpd_log.c.orig
|
||||
+++ slpd/slpd_log.c
|
||||
@@ -99,11 +99,11 @@ int SLPDLogFileOpen(const char* path, in
|
||||
#endif
|
||||
if (append)
|
||||
{
|
||||
- G_SlpdLogFile = fopen(path,"a");
|
||||
+ G_SlpdLogFile = fopen(path,"ae");
|
||||
}
|
||||
else
|
||||
{
|
||||
- G_SlpdLogFile = fopen(path,"w");
|
||||
+ G_SlpdLogFile = fopen(path,"we");
|
||||
}
|
||||
|
||||
if (G_SlpdLogFile == 0)
|
||||
--- slpd/slpd_property.c.orig
|
||||
+++ slpd/slpd_property.c
|
||||
@@ -80,7 +80,7 @@ int SLPDPropertyInit(const char* conffil
|
||||
|
||||
if (conffile)
|
||||
{
|
||||
- G_SlpdConffileFP = fopen(conffile, "r");
|
||||
+ G_SlpdConffileFP = fopen(conffile, "re");
|
||||
if (G_SlpdConffileFP)
|
||||
{
|
||||
SLPPropertySet("net.slp.OpenSLPConfigFile",conffile);
|
||||
--- slpd/slpd_socket.c.orig
|
||||
+++ slpd/slpd_socket.c
|
||||
@@ -333,7 +333,7 @@ SLPDSocket* SLPDSocketCreateDatagram(str
|
||||
if(sock->recvbuf && sock->sendbuf)
|
||||
{
|
||||
|
||||
- sock->fd = socket(PF_INET, SOCK_DGRAM, 0);
|
||||
+ sock->fd = socket(PF_INET, SOCK_DGRAM|SOCK_CLOEXEC, 0);
|
||||
if(sock->fd >=0)
|
||||
{
|
||||
switch(type)
|
||||
@@ -409,7 +409,7 @@ SLPDSocket* SLPDSocketCreateBoundDatagra
|
||||
{
|
||||
sock->recvbuf = SLPBufferAlloc(SLP_MAX_DATAGRAM_SIZE);
|
||||
sock->sendbuf = SLPBufferAlloc(SLP_MAX_DATAGRAM_SIZE);
|
||||
- sock->fd = socket(PF_INET, SOCK_DGRAM, 0);
|
||||
+ sock->fd = socket(PF_INET, SOCK_DGRAM|SOCK_CLOEXEC, 0);
|
||||
if(sock->fd >=0)
|
||||
{
|
||||
if(myaddr != NULL)
|
||||
@@ -478,7 +478,7 @@ SLPDSocket* SLPDSocketCreateListen(struc
|
||||
sock = SLPDSocketAlloc();
|
||||
if(sock)
|
||||
{
|
||||
- sock->fd = socket(PF_INET, SOCK_STREAM, 0);
|
||||
+ sock->fd = socket(PF_INET, SOCK_STREAM|SOCK_CLOEXEC|SOCK_NONBLOCK, 0);
|
||||
if(sock->fd >= 0)
|
||||
{
|
||||
if(peeraddr != NULL)
|
||||
@@ -492,9 +492,6 @@ SLPDSocket* SLPDSocketCreateListen(struc
|
||||
#ifdef _WIN32
|
||||
fdflags = 1;
|
||||
ioctlsocket(sock->fd, FIONBIO, &fdflags);
|
||||
-#else
|
||||
- fdflags = fcntl(sock->fd, F_GETFL, 0);
|
||||
- fcntl(sock->fd,F_SETFL, fdflags | O_NONBLOCK);
|
||||
#endif
|
||||
sock->state = SOCKET_LISTEN;
|
||||
|
||||
@@ -540,7 +537,7 @@ SLPDSocket* SLPDSocketCreateConnected(st
|
||||
}
|
||||
|
||||
/* create the stream socket */
|
||||
- sock->fd = socket(PF_INET,SOCK_STREAM,0);
|
||||
+ sock->fd = socket(PF_INET,SOCK_STREAM|SOCK_CLOEXEC|SOCK_NONBLOCK,0);
|
||||
if(sock->fd < 0)
|
||||
{
|
||||
goto FAILURE;
|
||||
@@ -550,9 +547,6 @@ SLPDSocket* SLPDSocketCreateConnected(st
|
||||
#ifdef _WIN32
|
||||
fdflags = 1;
|
||||
ioctlsocket(sock->fd, FIONBIO, &fdflags);
|
||||
-#else
|
||||
- fdflags = fcntl(sock->fd, F_GETFL, 0);
|
||||
- fcntl(sock->fd,F_SETFL, fdflags | O_NONBLOCK);
|
||||
#endif
|
||||
|
||||
/* zero then set peeraddr to connect to */
|
||||
--- slpd/slpd_database.c.orig
|
||||
+++ slpd/slpd_database.c
|
||||
@@ -877,7 +877,7 @@ int SLPDDatabaseInit(const char* regfile
|
||||
{
|
||||
fclose(regfileFP);
|
||||
}
|
||||
- regfileFP = fopen(regfile, "r");
|
||||
+ regfileFP = fopen(regfile, "re");
|
||||
return SLPDDatabaseReInit();
|
||||
}
|
||||
|
||||
@@ -958,7 +958,7 @@ enum {
|
||||
|
||||
static int reconnect_nl(int *fd)
|
||||
{
|
||||
- int new_fd = socket(AF_NETLINK, SOCK_RAW, NETLINK_INET_DIAG);
|
||||
+ int new_fd = socket(AF_NETLINK, SOCK_RAW|SOCK_CLOEXEC, NETLINK_INET_DIAG);
|
||||
|
||||
close (*fd);
|
||||
|
||||
@@ -1115,15 +1115,15 @@ void SLPDDatabaseWatcher(void)
|
||||
SLPSrvReg* srvreg;
|
||||
|
||||
if (!initialized) {
|
||||
- inet_diag = socket(AF_NETLINK, SOCK_RAW, NETLINK_INET_DIAG);
|
||||
- proctcp = open("/proc/net/tcp_listen", O_RDONLY);
|
||||
+ inet_diag = socket(AF_NETLINK, SOCK_RAW|SOCK_CLOEXEC, NETLINK_INET_DIAG);
|
||||
+ proctcp = open("/proc/net/tcp_listen", O_RDONLY|O_CLOEXEC);
|
||||
if (proctcp == -1)
|
||||
- proctcp = open("/proc/net/tcp", O_RDONLY);
|
||||
- procudp = open("/proc/net/udp", O_RDONLY);
|
||||
- proctcp6 = open("/proc/net/tcp6_listen", O_RDONLY);
|
||||
+ proctcp = open("/proc/net/tcp", O_RDONLY|O_CLOEXEC);
|
||||
+ procudp = open("/proc/net/udp", O_RDONLY|O_CLOEXEC);
|
||||
+ proctcp6 = open("/proc/net/tcp6_listen", O_RDONLY|O_CLOEXEC);
|
||||
if (proctcp6 == -1)
|
||||
- proctcp6 = open("/proc/net/tcp6", O_RDONLY);
|
||||
- procudp6 = open("/proc/net/udp6", O_RDONLY);
|
||||
+ proctcp6 = open("/proc/net/tcp6", O_RDONLY|O_CLOEXEC);
|
||||
+ procudp6 = open("/proc/net/udp6", O_RDONLY|O_CLOEXEC);
|
||||
initialized = 1;
|
||||
}
|
||||
flags = 0;
|
||||
@@ -1237,7 +1237,7 @@ int SLPDDatabaseReInit()
|
||||
|
||||
if ( strlen(filename)>4 &&
|
||||
strcmp(filename+strlen(filename)-4, ".reg") == 0 &&
|
||||
- (fd=fopen(filename,"rb")) )
|
||||
+ (fd=fopen(filename,"rbe")) )
|
||||
{
|
||||
while ( SLPDRegFileReadSrvReg(fd, SLP_REG_SOURCE_STATIC, &msg, &buf) == 0 )
|
||||
{
|
||||
--- common/slp_property.c.orig
|
||||
+++ common/slp_property.c
|
||||
@@ -345,7 +345,7 @@ int SLPPropertyReadFile(const char* conf
|
||||
FILE* fp;
|
||||
int ret;
|
||||
|
||||
- fp = fopen(conffile,"r");
|
||||
+ fp = fopen(conffile,"re");
|
||||
if (fp)
|
||||
{
|
||||
/* Set the property that keeps track of conffile */
|
||||
--- slpd/slpd_mdns.c.orig
|
||||
+++ slpd/slpd_mdns.c
|
||||
@@ -70,7 +70,7 @@ SLPDSocket* SLPDMDNSCreateBoundDatagram(
|
||||
sock->ifaddr.sin_addr = *myaddr;
|
||||
sock->recvbuf = SLPBufferAlloc(MDNS_MAX_DATAGRAM_SIZE);
|
||||
sock->sendbuf = SLPBufferAlloc(MDNS_MAX_DATAGRAM_SIZE);
|
||||
- sock->fd = socket(PF_INET, SOCK_DGRAM, 0);
|
||||
+ sock->fd = socket(PF_INET, SOCK_DGRAM|SOCK_CLOEXEC, 0);
|
||||
if (sock->fd < 0)
|
||||
{
|
||||
SLPDSocketFree(sock);
|
||||
--- common/slp_xcast.c.orig
|
||||
+++ common/slp_xcast.c
|
||||
@@ -116,7 +116,7 @@ int SLPBroadcastSend(const SLPIfaceInfo*
|
||||
socks->sock_count < ifaceinfo->iface_count;
|
||||
socks->sock_count++)
|
||||
{
|
||||
- socks->sock[socks->sock_count] = socket(AF_INET, SOCK_DGRAM, 0);
|
||||
+ socks->sock[socks->sock_count] = socket(AF_INET, SOCK_DGRAM|SOCK_CLOEXEC, 0);
|
||||
if (socks->sock[socks->sock_count] < 0)
|
||||
{
|
||||
/* error creating socket */
|
||||
@@ -190,7 +190,7 @@ int SLPMulticastSend(const SLPIfaceInfo*
|
||||
socks->sock_count < ifaceinfo->iface_count;
|
||||
socks->sock_count++)
|
||||
{
|
||||
- socks->sock[socks->sock_count] = socket(AF_INET, SOCK_DGRAM, 0);
|
||||
+ socks->sock[socks->sock_count] = socket(AF_INET, SOCK_DGRAM|SOCK_CLOEXEC, 0);
|
||||
if (socks->sock[socks->sock_count] < 0)
|
||||
{
|
||||
/* error creating socket */
|
||||
--- common/slp_dhcp.c.orig
|
||||
+++ common/slp_dhcp.c
|
||||
@@ -135,7 +135,7 @@ static int dhcpCreateBCSkt(struct sockad
|
||||
#endif
|
||||
|
||||
/* setup dhcp broadcast-to-server address structure */
|
||||
- if((sockfd = socket(AF_INET, SOCK_DGRAM, 0)) >= 0)
|
||||
+ if((sockfd = socket(AF_INET, SOCK_DGRAM|SOCK_CLOEXEC, 0)) >= 0)
|
||||
{
|
||||
struct sockaddr_in localaddr;
|
||||
|
||||
@@ -369,7 +369,7 @@ static int dhcpGetAddressInfo(unsigned c
|
||||
struct arpreq arpreq;
|
||||
struct sockaddr_in *sin;
|
||||
|
||||
- if ((sockfd = socket(AF_INET, SOCK_DGRAM, 0)) < 0)
|
||||
+ if ((sockfd = socket(AF_INET, SOCK_DGRAM|SOCK_CLOEXEC, 0)) < 0)
|
||||
return -1;
|
||||
|
||||
*hlen = 0;
|
||||
--- common/slp_network.c.orig
|
||||
+++ common/slp_network.c
|
||||
@@ -70,7 +70,7 @@ int SLPNetworkConnectStream(struct socka
|
||||
|
||||
/* TODO: Make this connect non-blocking so that it will timeout */
|
||||
|
||||
- result = socket(AF_INET,SOCK_STREAM,0);
|
||||
+ result = socket(AF_INET,SOCK_STREAM|SOCK_CLOEXEC,0);
|
||||
if(result >= 0)
|
||||
{
|
||||
if(connect(result,
|
||||
@@ -132,7 +132,7 @@ int SLPNetworkConnectToMulticast(struct
|
||||
|
||||
|
||||
/* setup multicast socket */
|
||||
- sockfd = socket(AF_INET,SOCK_DGRAM,0);
|
||||
+ sockfd = socket(AF_INET,SOCK_DGRAM|SOCK_CLOEXEC,0);
|
||||
if(sockfd >= 0)
|
||||
{
|
||||
peeraddr->sin_family = AF_INET;
|
||||
@@ -190,7 +190,7 @@ int SLPNetworkConnectToBroadcast(struct
|
||||
|
||||
|
||||
/* setup broadcast */
|
||||
- sockfd = socket(AF_INET, SOCK_DGRAM, 0);
|
||||
+ sockfd = socket(AF_INET, SOCK_DGRAM|SOCK_CLOEXEC, 0);
|
||||
if(sockfd >= 0)
|
||||
{
|
||||
peeraddr->sin_family = AF_INET;
|
||||
--- common/slp_xmalloc.c.orig
|
||||
+++ common/slp_xmalloc.c
|
||||
@@ -317,7 +317,7 @@ char* _xstrdup(const char* file,
|
||||
int xmalloc_init(const char* filename, size_t freemem)
|
||||
/*=========================================================================*/
|
||||
{
|
||||
- G_xmalloc_fh = fopen(filename, "w");
|
||||
+ G_xmalloc_fh = fopen(filename, "we");
|
||||
if(G_xmalloc_fh)
|
||||
{
|
||||
return 0;
|
||||
--- common/slp_spi.c.orig
|
||||
+++ common/slp_spi.c
|
||||
@@ -112,7 +112,7 @@ SLPCryptoDSAKey* SLPSpiReadKeyFile(const
|
||||
FILE* fp;
|
||||
SLPCryptoDSAKey* result = 0;
|
||||
|
||||
- fp = fopen(keyfile,"r");
|
||||
+ fp = fopen(keyfile,"re");
|
||||
if(fp)
|
||||
{
|
||||
if(keytype == SLPSPI_KEY_TYPE_PUBLIC)
|
||||
@@ -264,7 +264,7 @@ SLPSpiHandle SLPSpiOpen(const char* spif
|
||||
SLPSpiHandle result = 0;
|
||||
SLPSpiEntry* spientry;
|
||||
|
||||
- fp = fopen(spifile,"r");
|
||||
+ fp = fopen(spifile,"re");
|
||||
if(fp)
|
||||
{
|
||||
result = xmalloc(sizeof(struct _SLPSpiHandle));
|
||||
--- common/slp_iface.c.orig
|
||||
+++ common/slp_iface.c
|
||||
@@ -111,7 +111,7 @@ int SLPIfaceGetInfo(const char* useiface
|
||||
ifc.ifc_len = sizeof(struct ifreq) * SLP_MAX_IFACES ;
|
||||
ifc.ifc_req = ifrlist;
|
||||
|
||||
- fd = socket(AF_INET,SOCK_STREAM,0);
|
||||
+ fd = socket(AF_INET,SOCK_STREAM|SOCK_CLOEXEC,0);
|
||||
if(fd == -1)
|
||||
{
|
||||
/* failed to create socket */
|
||||
--- libslp/libslp_network.c.orig
|
||||
+++ libslp/libslp_network.c
|
||||
@@ -68,7 +68,7 @@ int NetworkConnectToSlpd(struct sockaddr
|
||||
#endif
|
||||
int result;
|
||||
|
||||
- result = socket(AF_INET,SOCK_STREAM,0);
|
||||
+ result = socket(AF_INET,SOCK_STREAM|SOCK_CLOEXEC,0);
|
||||
if(result >= 0)
|
||||
{
|
||||
peeraddr->sin_family = AF_INET;
|
||||
--- libslp/libslp_mdns.c.orig
|
||||
+++ libslp/libslp_mdns.c
|
||||
@@ -665,7 +665,7 @@ int SLPMDNSMulticastSend(const SLPIfaceI
|
||||
socks->sock_count < ifaceinfo->iface_count;
|
||||
socks->sock_count++)
|
||||
{
|
||||
- socks->sock[socks->sock_count] = socket(AF_INET, SOCK_DGRAM, 0);
|
||||
+ socks->sock[socks->sock_count] = socket(AF_INET, SOCK_DGRAM|SOCK_CLOEXEC, 0);
|
||||
if (socks->sock[socks->sock_count] < 0)
|
||||
{
|
||||
/* error creating socket */
|
||||
@@ -892,7 +892,7 @@ int SLPMDNSXcastRecvMessage(const SLPXca
|
||||
mhdr.msg_control = cmsgbuf;
|
||||
mhdr.msg_controllen = sizeof(cmsgbuf);
|
||||
mhdr.msg_flags = 0;
|
||||
- bytesread = recvmsg(mdnssockets->sock[i], &mhdr, 0);
|
||||
+ bytesread = recvmsg(mdnssockets->sock[i], &mhdr, MSG_CMSG_CLOEXEC);
|
||||
if (bytesread < 12)
|
||||
continue;
|
||||
cmsg = CMSG_FIRSTHDR(&mhdr);
|
||||
--- configure.in.orig
|
||||
+++ configure.in
|
||||
@@ -111,7 +111,9 @@ fi
|
||||
dnl ***********************************************************************
|
||||
dnl Checks for programs.
|
||||
dnl ***********************************************************************
|
||||
-AC_PROG_CC
|
||||
+AC_PROG_CC_STDC
|
||||
+AC_USE_SYSTEM_EXTENSIONS
|
||||
+AC_SYS_LARGEFILE
|
||||
AC_PROG_INSTALL
|
||||
AM_PROG_LIBTOOL
|
||||
AM_PROG_LEX
|
@ -1,540 +1,33 @@
|
||||
--- ./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
|
||||
--- ./common/slp_network.c.orig 2014-02-13 15:14:30.020870347 +0000
|
||||
+++ ./common/slp_network.c 2014-02-13 15:36:48.344867978 +0000
|
||||
@@ -303,6 +303,8 @@ int SLPNetworkRecvMessage(sockfd_t sockf
|
||||
{
|
||||
@@ -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 */
|
||||
/* Allocate the receive buffer as large as necessary. */
|
||||
recvlen = PEEK_LENGTH(peek);
|
||||
+ if (recvlen <= 0)
|
||||
+ recvlen = 1;
|
||||
+ *buf = SLPBufferRealloc(*buf, recvlen);
|
||||
*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. */
|
||||
/*=========================================================================*/
|
||||
--- ./slpd/slpd_incoming.c.orig 2014-02-13 15:14:30.022870347 +0000
|
||||
+++ ./slpd/slpd_incoming.c 2014-02-13 15:36:12.992868041 +0000
|
||||
@@ -241,6 +241,8 @@ static void IncomingStreamRead(SLPList *
|
||||
if (bytesread > 0 && bytesread >= (*peek == 2? 5: 4))
|
||||
{
|
||||
+ 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 */
|
||||
recvlen = PEEK_LENGTH(peek);
|
||||
+ 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
|
||||
--- ./slpd/slpd_outgoing.c.orig 2014-02-13 15:14:30.022870347 +0000
|
||||
+++ ./slpd/slpd_outgoing.c 2014-02-13 15:34:49.984868188 +0000
|
||||
@@ -211,6 +211,8 @@ void OutgoingStreamRead(SLPList * sockli
|
||||
{
|
||||
- /* 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);
|
||||
msglen = PEEK_LENGTH(peek);
|
||||
+ if (msglen <= 0)
|
||||
+ msglen = 1;
|
||||
|
||||
sock->recvbuf = SLPBufferRealloc(sock->recvbuf, msglen);
|
||||
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 */
|
||||
|
@ -1,3 +1,48 @@
|
||||
-------------------------------------------------------------------
|
||||
Wed Feb 19 18:37:01 CET 2014 - mls@suse.de
|
||||
|
||||
- update to openslp-2.0.0 to get IPv6 support
|
||||
* dropped patches:
|
||||
v1dadiscovery.diff, openslp.clrflags.diff
|
||||
openslp.fixdsareturn.diff, openslp.dereg.diff,
|
||||
openslp.tcpclearovr.diff, openslp.lifetime.diff,
|
||||
slptool-timeout.diff, openslp.poll.diff,
|
||||
openslp.ignorespaces.diff, openslp.checkovr.diff,
|
||||
openslp.fixaddrcheck.diff, openslp.loopbacksocket.diff,
|
||||
openslp.diff, openslp.doubleequal.diff, openslp.discovery.diff,
|
||||
openslp.parseext.diff, openslp.knowndafree.diff,
|
||||
openslp.emptyanswer.diff, openslp.v1sladdr.diff, hppa.diff
|
||||
* renamed patches:
|
||||
openslp-1.2.0-visibility.patch -> openslp.visibility.diff
|
||||
openslp-1.2.0-daemon.diff -> openslp.daemon.diff
|
||||
openslp.use-TCPDIAG-for-checking-listeners -> openslp.netlink.diff
|
||||
openslp-ocloexec.patch -> openslp.cloexec.diff
|
||||
- always use localtime in the log file [bnc#855385]
|
||||
patch: openslp.localtime.diff
|
||||
- use tcp to connect to the local SA
|
||||
patch: openslp.tcplocal.diff
|
||||
- drop unused mdns support
|
||||
- rename README.SuSE to README.SUSE
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Thu Feb 13 15:03:15 CET 2014 - mls@suse.de
|
||||
|
||||
- frontport SLE11 patches:
|
||||
* add hardMTU option to limit the datagram package size to
|
||||
1400 bytes [bnc#648384].
|
||||
patch: openslp.hardmtu.diff
|
||||
* fix double free in SLPDKnownDAAdd error case [bnc#667953]
|
||||
patch: openslp.knowndafree.diff
|
||||
* fix libslp socket handling, check if socket is still alive
|
||||
and fix socket close code [bnc#693756]
|
||||
patch: openslp.loopbacksocket.diff
|
||||
* make openslpd reconnect to DAs if they closed the connection
|
||||
[bnc#723385]
|
||||
patch: openslp.slpdreconnect.diff
|
||||
* fixup lifetime of registrations a bit so that they
|
||||
don't get removed too early [bnc#658972]
|
||||
patch: openslp.lifetime.diff
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Tue Jul 16 13:44:12 CEST 2013 - mls@suse.de
|
||||
|
||||
|
@ -1,57 +0,0 @@
|
||||
--- ./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;
|
211
openslp.cloexec.diff
Normal file
211
openslp.cloexec.diff
Normal file
@ -0,0 +1,211 @@
|
||||
--- ./common/slp_dhcp.c.orig 2014-02-17 18:16:57.883239271 +0000
|
||||
+++ ./common/slp_dhcp.c 2014-02-17 18:20:16.386238920 +0000
|
||||
@@ -101,7 +101,7 @@ static sockfd_t dhcpCreateBCSkt(void * p
|
||||
so_bool_t on = 1;
|
||||
|
||||
/* setup dhcp broadcast-to-server address structure */
|
||||
- if ((sockfd = socket(AF_INET, SOCK_DGRAM, 0)) != SLP_INVALID_SOCKET)
|
||||
+ if ((sockfd = socket(AF_INET, SOCK_DGRAM|SOCK_CLOEXEC, 0)) != SLP_INVALID_SOCKET)
|
||||
{
|
||||
int addr = INADDR_ANY;
|
||||
struct sockaddr_storage localaddr;
|
||||
@@ -355,7 +355,7 @@ static int dhcpGetAddressInfo(unsigned c
|
||||
struct arpreq arpreq;
|
||||
struct sockaddr_in * sin;
|
||||
|
||||
- if ((sockfd = socket(AF_INET, SOCK_DGRAM, 0)) == SLP_INVALID_SOCKET)
|
||||
+ if ((sockfd = socket(AF_INET, SOCK_DGRAM|SOCK_CLOEXEC, 0)) == SLP_INVALID_SOCKET)
|
||||
return -1;
|
||||
|
||||
*hlen = 0;
|
||||
--- ./common/slp_iface.c.orig 2014-02-17 18:16:57.886239271 +0000
|
||||
+++ ./common/slp_iface.c 2014-02-17 18:21:25.194238798 +0000
|
||||
@@ -457,7 +457,7 @@ static int GetV6Scope(struct sockaddr_in
|
||||
family = AF_INET6;
|
||||
|
||||
/* Check if address is a global address and if it is then assign a scope ID as zero */
|
||||
- fd = socket(AF_INET6, SOCK_STREAM, IPPROTO_TCP);
|
||||
+ fd = socket(AF_INET6, SOCK_STREAM|SOCK_CLOEXEC, IPPROTO_TCP);
|
||||
if (fd != INVALID_SOCKET)
|
||||
{
|
||||
if (addr != NULL )
|
||||
@@ -552,7 +552,7 @@ static int GetV6Scope(struct sockaddr_in
|
||||
xfree(pAddr);
|
||||
#else
|
||||
sockfd_t fd;
|
||||
- fd = socket(AF_INET6, SOCK_STREAM, IPPROTO_TCP);
|
||||
+ fd = socket(AF_INET6, SOCK_STREAM|SOCK_CLOEXEC, IPPROTO_TCP);
|
||||
if (fd != SLP_INVALID_SOCKET)
|
||||
{
|
||||
/* This loop attempts to find the proper scope value
|
||||
@@ -698,7 +698,7 @@ int SLPIfaceGetDefaultInfo(SLPIfaceInfo
|
||||
#ifdef LINUX
|
||||
SLPIfaceGetV6Addr(ifaceinfo);
|
||||
#else
|
||||
- fd = socket(AF_INET6, SOCK_DGRAM, 0);
|
||||
+ fd = socket(AF_INET6, SOCK_DGRAM|SOCK_CLOEXEC, 0);
|
||||
if (fd != -1)
|
||||
{
|
||||
#ifdef AIX
|
||||
@@ -739,7 +739,7 @@ int SLPIfaceGetDefaultInfo(SLPIfaceInfo
|
||||
|
||||
if ((family == AF_INET) || (family == AF_UNSPEC))
|
||||
{
|
||||
- fd = socket(AF_INET, SOCK_DGRAM, 0);
|
||||
+ fd = socket(AF_INET, SOCK_DGRAM|SOCK_CLOEXEC, 0);
|
||||
if (fd != -1)
|
||||
{
|
||||
#ifdef AIX
|
||||
@@ -813,7 +813,7 @@ int SLPIfaceGetDefaultInfo(SLPIfaceInfo*
|
||||
SOCKET_ADDRESS_LIST * plist = 0;
|
||||
int i;
|
||||
|
||||
- if ((fd = socket(AF_INET6, SOCK_DGRAM, 0)) != INVALID_SOCKET)
|
||||
+ if ((fd = socket(AF_INET6, SOCK_DGRAM|SOCK_CLOEXEC, 0)) != INVALID_SOCKET)
|
||||
{
|
||||
/* We want to get a reasonable length buffer, so call empty first to fill in buflen, ignoring errors*/
|
||||
WSAIoctl(fd, SIO_ADDRESS_LIST_QUERY, 0, 0, buffer, buflen, &buflen, 0, 0);
|
||||
@@ -850,7 +850,7 @@ int SLPIfaceGetDefaultInfo(SLPIfaceInfo*
|
||||
SOCKET_ADDRESS_LIST * plist = 0;
|
||||
int i;
|
||||
|
||||
- if ((fd = socket(AF_INET, SOCK_DGRAM, 0)) != INVALID_SOCKET)
|
||||
+ if ((fd = socket(AF_INET, SOCK_DGRAM|SOCK_CLOEXEC, 0)) != INVALID_SOCKET)
|
||||
{
|
||||
/* We want to get a reasonable length buffer, so call empty first to fill in buflen, ignoring errors */
|
||||
WSAIoctl(fd, SIO_ADDRESS_LIST_QUERY, 0, 0, buffer, buflen, &buflen, 0, 0);
|
||||
@@ -1054,7 +1054,7 @@ int SLPIfaceGetInfo(const char * useifac
|
||||
{
|
||||
if (SLPNetIsIPV4() && ((family == AF_INET) || (family == AF_UNSPEC)))
|
||||
{
|
||||
- fd = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
|
||||
+ fd = socket(AF_INET, SOCK_STREAM|SOCK_CLOEXEC, IPPROTO_TCP);
|
||||
if (fd != SLP_INVALID_SOCKET)
|
||||
{
|
||||
v4addr.sin_family = AF_INET;
|
||||
--- ./common/slp_network.c.orig 2014-02-17 18:16:57.884239271 +0000
|
||||
+++ ./common/slp_network.c 2014-02-17 18:21:48.434238757 +0000
|
||||
@@ -88,7 +88,7 @@ sockfd_t SLPNetworkConnectStream(void *
|
||||
(void)timeout;
|
||||
/** @todo Make the socket non-blocking so we can timeout on connect. */
|
||||
|
||||
- result = socket(a->sa_family, SOCK_STREAM, IPPROTO_TCP);
|
||||
+ result = socket(a->sa_family, SOCK_STREAM|SOCK_CLOEXEC, IPPROTO_TCP);
|
||||
if (result != SLP_INVALID_SOCKET)
|
||||
{
|
||||
if (connect(result, peeraddr, sizeof(struct sockaddr_storage)) == 0)
|
||||
@@ -127,7 +127,7 @@ sockfd_t SLPNetworkCreateDatagram(short
|
||||
recvfrom will fail on some platforms*/
|
||||
sockfd_t result;
|
||||
|
||||
- result = socket(family, SOCK_DGRAM, IPPROTO_UDP);
|
||||
+ result = socket(family, SOCK_DGRAM|SOCK_CLOEXEC, IPPROTO_UDP);
|
||||
if (result != SLP_INVALID_SOCKET)
|
||||
{
|
||||
#ifndef _WIN32
|
||||
--- ./common/slp_property.c.orig 2014-02-17 18:16:53.361239279 +0000
|
||||
+++ ./common/slp_property.c 2014-02-17 18:23:39.306238561 +0000
|
||||
@@ -217,7 +217,7 @@ static void InitializeMTUPropertyValue()
|
||||
#ifndef _WIN32
|
||||
family = SLPPropertyAsBoolean("net.slp.useIPv4") ? AF_INET : AF_INET6;
|
||||
|
||||
- if ((sock = socket(family, SOCK_DGRAM, 0)) != SLP_INVALID_SOCKET)
|
||||
+ if ((sock = socket(family, SOCK_DGRAM|SOCK_CLOEXEC, 0)) != SLP_INVALID_SOCKET)
|
||||
{
|
||||
if (getsockopt(sock, SOL_SOCKET, SO_RCVBUF, &value, &valSize) != -1)
|
||||
{
|
||||
@@ -311,7 +311,7 @@ static bool ReadFileProperties(char cons
|
||||
rewind(conffp);
|
||||
|
||||
/* open configuration file for read - missing file returns false */
|
||||
- if ((fp = s_UsePropertyFps ? conffp : fopen(conffile, "r")) != 0)
|
||||
+ if ((fp = s_UsePropertyFps ? conffp : fopen(conffile, "re")) != 0)
|
||||
{
|
||||
/* read a line at a time - max 4k characters per line */
|
||||
while (fgets(alloced, CONFFILE_RDBUFSZ, fp))
|
||||
@@ -400,11 +400,11 @@ static int ReadPropertyFiles(void)
|
||||
if (s_UsePropertyFps == 1)
|
||||
{
|
||||
if (*s_GlobalPropertyFile)
|
||||
- s_GlobalPropertyFp = fopen(s_GlobalPropertyFile, "r");
|
||||
+ s_GlobalPropertyFp = fopen(s_GlobalPropertyFile, "re");
|
||||
if (*s_EnvPropertyFile)
|
||||
- s_EnvPropertyFp = fopen(s_EnvPropertyFile, "r");
|
||||
+ s_EnvPropertyFp = fopen(s_EnvPropertyFile, "re");
|
||||
if (*s_AppPropertyFile)
|
||||
- s_AppPropertyFp = fopen(s_AppPropertyFile, "r");
|
||||
+ s_AppPropertyFp = fopen(s_AppPropertyFile, "re");
|
||||
s_UsePropertyFps = 2;
|
||||
}
|
||||
|
||||
--- ./common/slp_spi.c.orig 2014-02-17 18:16:57.885239271 +0000
|
||||
+++ ./common/slp_spi.c 2014-02-17 18:23:08.570238615 +0000
|
||||
@@ -124,7 +124,7 @@ static SLPCryptoDSAKey * SLPSpiReadKeyFi
|
||||
FILE * fp;
|
||||
SLPCryptoDSAKey * result = 0;
|
||||
|
||||
- fp = fopen(keyfile, "r");
|
||||
+ fp = fopen(keyfile, "re");
|
||||
if (fp)
|
||||
{
|
||||
if (keytype == SLPSPI_KEY_TYPE_PUBLIC)
|
||||
@@ -262,7 +262,7 @@ SLPSpiHandle SLPSpiOpen(const char * spi
|
||||
SLPSpiHandle result = 0;
|
||||
SLPSpiEntry * spientry;
|
||||
|
||||
- fp = fopen(spifile,"r");
|
||||
+ fp = fopen(spifile,"re");
|
||||
if (fp)
|
||||
{
|
||||
result = xmalloc(sizeof(struct _SLPSpiHandle));
|
||||
--- ./common/slp_xcast.c.orig 2014-02-17 18:16:57.882239271 +0000
|
||||
+++ ./common/slp_xcast.c 2014-02-17 18:22:40.010238666 +0000
|
||||
@@ -79,7 +79,7 @@ int SLPBroadcastSend(const SLPIfaceInfo
|
||||
if (ifaceinfo[socks->sock_count].bcast_addr->ss_family == AF_INET)
|
||||
{
|
||||
socks->sock[socks->sock_count] = socket(ifaceinfo[socks->sock_count]
|
||||
- .bcast_addr->ss_family, SOCK_DGRAM, 0);
|
||||
+ .bcast_addr->ss_family, SOCK_DGRAM|SOCK_CLOEXEC, 0);
|
||||
|
||||
if (socks->sock[socks->sock_count] == SLP_INVALID_SOCKET)
|
||||
return -1; /* error creating socket */
|
||||
@@ -190,7 +190,7 @@ int SLPMulticastSend(const SLPIfaceInfo
|
||||
{
|
||||
int family = ifaceinfo->iface_addr[socks->sock_count].ss_family;
|
||||
|
||||
- socks->sock[socks->sock_count] = socket(family, SOCK_DGRAM, 0);
|
||||
+ socks->sock[socks->sock_count] = socket(family, SOCK_DGRAM|SOCK_CLOEXEC, 0);
|
||||
if((socks->sock[socks->sock_count] == SLP_INVALID_SOCKET) ||
|
||||
(SetMulticastIF(family, socks->sock[socks->sock_count], &ifaceinfo->iface_addr[socks->sock_count]) ||
|
||||
(SetMulticastTTL(family, socks->sock[socks->sock_count], SLPPropertyAsInteger("net.slp.multicastTTL")))))
|
||||
--- ./common/slp_xmalloc.c.orig 2014-02-17 18:16:57.884239271 +0000
|
||||
+++ ./common/slp_xmalloc.c 2014-02-17 18:23:17.506238600 +0000
|
||||
@@ -292,7 +292,7 @@ void _xfree(const char * file, int line,
|
||||
*/
|
||||
int xmalloc_init(const char * filename, size_t freemem)
|
||||
{
|
||||
- G_xmalloc_fh = fopen(filename, "w");
|
||||
+ G_xmalloc_fh = fopen(filename, "we");
|
||||
if (G_xmalloc_fh == 0)
|
||||
return 0;
|
||||
G_xmalloc_freemem = freemem;
|
||||
--- ./libslp/libslp_network.c.orig 2014-02-17 18:16:57.888239271 +0000
|
||||
+++ ./libslp/libslp_network.c 2014-02-17 18:18:05.498239152 +0000
|
||||
@@ -1618,7 +1618,7 @@ SLPError NetworkMultiUcastRqstRply(
|
||||
/*----------------------------------------*/
|
||||
/* Create a UDP socket to use */
|
||||
/*----------------------------------------*/
|
||||
- udp_socket = socket(AF_INET, SOCK_DGRAM, 0);
|
||||
+ udp_socket = socket(AF_INET, SOCK_DGRAM|SOCK_CLOEXEC, 0);
|
||||
if (udp_socket < 0)
|
||||
{
|
||||
result = SLP_NETWORK_ERROR;
|
||||
@@ -2092,7 +2092,7 @@ SLPError NetworkMultiUcastRqstRply(
|
||||
if (result == SLP_ERROR_RETRY_UNICAST)
|
||||
{
|
||||
result = SLP_OK;
|
||||
- pconn->socket = socket(AF_INET, SOCK_STREAM, 0);
|
||||
+ pconn->socket = socket(AF_INET, SOCK_STREAM||SOCK_CLOEXEC, 0);
|
||||
if (pconn->socket < 0)
|
||||
{
|
||||
result = SLP_NETWORK_ERROR;
|
@ -1,17 +0,0 @@
|
||||
--- slpd/slpd_process.c.orig 2009-09-15 11:39:31.000000000 +0200
|
||||
+++ slpd/slpd_process.c 2009-09-15 11:45:12.000000000 +0200
|
||||
@@ -216,9 +216,13 @@
|
||||
break;
|
||||
}
|
||||
|
||||
- /* TRICKY: fix up the xid */
|
||||
+ /* TRICKY: fix up the xid and clear flags */
|
||||
tmp->curpos = tmp->start + 10;
|
||||
ToUINT16(tmp->curpos, message->header.xid);
|
||||
+ if (*(tmp->start) == 1)
|
||||
+ *(tmp->start + 4) = 0;
|
||||
+ else
|
||||
+ ToUINT16(tmp->start + 5, 0);
|
||||
|
||||
memcpy((*sendbuf)->curpos, tmp->start, tmp->end - tmp->start);
|
||||
(*sendbuf)->curpos = ((*sendbuf)->curpos) + (tmp->end - tmp->start);
|
11
openslp.daemon.diff
Normal file
11
openslp.daemon.diff
Normal file
@ -0,0 +1,11 @@
|
||||
--- ./slpd/slpd_main.c.orig 2014-02-17 18:14:08.220239572 +0000
|
||||
+++ ./slpd/slpd_main.c 2014-02-17 18:14:37.546239520 +0000
|
||||
@@ -520,7 +520,7 @@ static int DropPrivileges()
|
||||
/* TODO: warn if 'daemon' user has insufficient privileges and ipv6 requested.*/
|
||||
/* TODO: allow different user to be specified as process owner. */
|
||||
|
||||
- struct passwd * pwent = getpwnam("daemon");
|
||||
+ struct passwd * pwent = getpwnam("openslp");
|
||||
if (pwent)
|
||||
{
|
||||
if (chroot(reg_file_dir))
|
@ -1,13 +0,0 @@
|
||||
--- libslp/libslp_dereg.c.orig 2002-10-08 13:47:56.000000000 +0000
|
||||
+++ libslp/libslp_dereg.c 2007-09-04 12:36:12.000000000 +0000
|
||||
@@ -197,8 +197,8 @@ SLPError ProcessSrvDeReg(PSLPHandleInfo
|
||||
/* Call the RqstRply engine */
|
||||
/*--------------------------*/
|
||||
sock = NetworkConnectToSA(handle,
|
||||
- handle->params.reg.scopelist,
|
||||
- handle->params.reg.scopelistlen,
|
||||
+ handle->params.dereg.scopelist,
|
||||
+ handle->params.dereg.scopelistlen,
|
||||
&peeraddr);
|
||||
if(sock >= 0)
|
||||
{
|
136
openslp.diff
136
openslp.diff
@ -1,136 +0,0 @@
|
||||
--- ./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));
|
||||
}
|
@ -1,58 +0,0 @@
|
||||
--- slpd/slpd_outgoing.c.orig 2009-12-22 15:23:09.000000000 +0000
|
||||
+++ slpd/slpd_outgoing.c 2009-12-22 15:47:35.000000000 +0000
|
||||
@@ -420,6 +420,24 @@ SLPDSocket* SLPDOutgoingConnect(struct i
|
||||
}
|
||||
|
||||
/*=========================================================================*/
|
||||
+int SLPDHaveOutgoingConnectedSocket(struct in_addr* addr)
|
||||
+/* Check if there is an outgoing socket for the specified address */
|
||||
+/* */
|
||||
+/* addr (IN) the address of the peer to check */
|
||||
+/*=========================================================================*/
|
||||
+{
|
||||
+ SLPDSocket* sock = (SLPDSocket*)G_OutgoingSocketList.head;
|
||||
+ while ( sock )
|
||||
+ {
|
||||
+ if (sock->state >= STREAM_CONNECT_IDLE &&
|
||||
+ sock->peeraddr.sin_addr.s_addr == addr->s_addr)
|
||||
+ return 1;
|
||||
+ sock = (SLPDSocket*)sock->listitem.next;
|
||||
+ }
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
+/*=========================================================================*/
|
||||
void SLPDOutgoingDatagramWrite(SLPDSocket* sock)
|
||||
/* Add a ready to write outgoing datagram socket to the outgoing list. */
|
||||
/* The datagram will be written then sit in the list until it ages out */
|
||||
--- slpd/slpd_outgoing.h.orig 2009-12-22 15:43:52.000000000 +0000
|
||||
+++ slpd/slpd_outgoing.h 2009-12-22 15:45:26.000000000 +0000
|
||||
@@ -107,6 +107,13 @@ SLPDSocket* SLPDOutgoingConnect(struct i
|
||||
/* returns: pointer to socket or null on error */
|
||||
/*=========================================================================*/
|
||||
|
||||
+/*=========================================================================*/
|
||||
+int SLPDHaveOutgoingConnectedSocket(struct in_addr* addr);
|
||||
+/* Check if there is an outgoing socket for the specified address */
|
||||
+/* */
|
||||
+/* addr (IN) the address of the peer to check */
|
||||
+/*=========================================================================*/
|
||||
+
|
||||
|
||||
/*=========================================================================*/
|
||||
int SLPDOutgoingInit();
|
||||
--- slpd/slpd_process.c.orig 2009-12-22 15:01:43.000000000 +0000
|
||||
+++ slpd/slpd_process.c 2009-12-22 15:43:20.000000000 +0000
|
||||
@@ -1120,7 +1120,11 @@ int ProcessDAAdvert(SLPMessage message,
|
||||
if(G_SlpdProperty.DAActiveDiscoveryInterval == 0 &&
|
||||
message->header.xid != 0)
|
||||
{
|
||||
- goto RESPOND;
|
||||
+ /* do not ignore replys of our DiscoveryRequests made for
|
||||
+ * static and dhcp configured DAs. For now we check this by
|
||||
+ * testing if the sockaddr is on the outgoing socket list */
|
||||
+ if (!SLPDHaveOutgoingConnectedSocket(&message->peer.sin_addr))
|
||||
+ goto RESPOND;
|
||||
}
|
||||
|
||||
/*-------------------------------*/
|
@ -1,59 +0,0 @@
|
||||
--- 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);
|
||||
|
@ -1,20 +0,0 @@
|
||||
--- 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;
|
@ -1,11 +0,0 @@
|
||||
--- common/slp_message.h.orig 2008-03-25 19:26:00.000000000 +0100
|
||||
+++ common/slp_message.h 2008-03-25 19:26:18.000000000 +0100
|
||||
@@ -495,7 +495,7 @@
|
||||
/*=========================================================================*/
|
||||
|
||||
|
||||
-#ifdef i386
|
||||
+#if 1
|
||||
|
||||
/*=========================================================================*/
|
||||
/* Macros to check in_addr */
|
@ -1,11 +0,0 @@
|
||||
--- ./common/slp_crypto.c.orig 2002-03-19 23:52:15.000000000 +0000
|
||||
+++ ./common/slp_crypto.c 2009-01-30 13:15:06.000000000 +0000
|
||||
@@ -179,5 +179,5 @@ int SLPCryptoDSAVerify(SLPCryptoDSAKey*
|
||||
digestlen,
|
||||
(unsigned char*)signature, /* broken DSA_verify() declaration */
|
||||
signaturelen,
|
||||
- key);
|
||||
-}
|
||||
\ No newline at end of file
|
||||
+ key) > 0 ? 1 : 0;
|
||||
+}
|
246
openslp.hardmtu.diff
Normal file
246
openslp.hardmtu.diff
Normal file
@ -0,0 +1,246 @@
|
||||
--- ./common/slp_property.c.orig 2014-02-18 17:14:52.119092941 +0000
|
||||
+++ ./common/slp_property.c 2014-02-18 17:15:01.462092925 +0000
|
||||
@@ -181,6 +181,8 @@ static int SetDefaultValues(void)
|
||||
{"net.slp.isDABackup", "false", 0},
|
||||
{"net.slp.DABackupInterval", "900", 0},
|
||||
{"net.slp.DABackupLocalReg", "false", 0},
|
||||
+
|
||||
+ {"net.slp.hardMTU", "false", 0},
|
||||
};
|
||||
|
||||
int i;
|
||||
--- ./etc/slp.conf.orig 2014-02-18 17:14:52.109092941 +0000
|
||||
+++ ./etc/slp.conf 2014-02-18 17:15:01.463092925 +0000
|
||||
@@ -168,6 +168,12 @@
|
||||
# A integer giving the network packet MTU in bytes. (Default is 1400)
|
||||
;net.slp.MTU = 1400
|
||||
|
||||
+# make sure that UDP packets really are smaller than the MTU. Normally
|
||||
+# openslp will truncate packets so that they are a bit bigger than
|
||||
+# the MTU, as a workaround for bugs in old openslp implementations.
|
||||
+# (Default is false)
|
||||
+;net.slp.hardMTU = false
|
||||
+
|
||||
#
|
||||
# If operating as an SA or DA, this specifies the maximum number of interfaces
|
||||
# that can be active. (Default is 100)
|
||||
--- ./slpd/slpd_incoming.c.orig 2014-02-18 17:14:52.103092941 +0000
|
||||
+++ ./slpd/slpd_incoming.c 2014-02-18 17:15:01.464092925 +0000
|
||||
@@ -89,6 +89,8 @@ static void IncomingDatagramRead(SLPList
|
||||
truncate = G_SlpdProperty.MTU;
|
||||
if (G_SlpdProperty.oversizedUDP)
|
||||
truncate = 0;
|
||||
+ if (G_SlpdProperty.hardMTU)
|
||||
+ truncate = G_SlpdProperty.MTU - 28;
|
||||
|
||||
if (!sock->sendbuf)
|
||||
/* Some of the error handling code expects a sendbuf to be available
|
||||
--- ./slpd/slpd_process.c.orig 2014-02-18 17:14:52.104092941 +0000
|
||||
+++ ./slpd/slpd_process.c 2014-02-18 17:19:11.508092482 +0000
|
||||
@@ -406,6 +406,7 @@ static int ProcessSrvRqst(SLPMessage * m
|
||||
SLPUrlEntry * urlentry;
|
||||
SLPDDatabaseSrvRqstResult * db = 0;
|
||||
size_t size = 0;
|
||||
+ int truncated = 0;
|
||||
SLPBuffer result = *sendbuf;
|
||||
|
||||
/* If errorcode is set, we can not be sure that message is good
|
||||
@@ -509,9 +510,14 @@ RESPOND:
|
||||
{
|
||||
for (i = 0; i < db->urlcount; i++)
|
||||
{
|
||||
+ int oldsize = size;
|
||||
+
|
||||
/* check size limitation */
|
||||
if (truncate && size > truncate)
|
||||
+ {
|
||||
+ truncated = 1;
|
||||
break;
|
||||
+ }
|
||||
|
||||
/* urlentry is the url from the db result */
|
||||
urlentry = db->urlarray[i];
|
||||
@@ -529,6 +535,12 @@ RESPOND:
|
||||
{
|
||||
size += urlentry->opaquelen;
|
||||
}
|
||||
+ if (G_SlpdProperty.hardMTU && truncate && size > truncate)
|
||||
+ {
|
||||
+ size = oldsize;
|
||||
+ truncated = 1;
|
||||
+ break;
|
||||
+ }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -552,7 +564,7 @@ RESPOND:
|
||||
PutUINT24(&result->curpos, size);
|
||||
|
||||
/* flags */
|
||||
- PutUINT16(&result->curpos, (size > (size_t)G_SlpdProperty.MTU?
|
||||
+ PutUINT16(&result->curpos, (truncated || size > (size_t)G_SlpdProperty.MTU?
|
||||
SLP_FLAG_OVERFLOW: 0));
|
||||
|
||||
/* ext offset */
|
||||
@@ -580,8 +592,12 @@ RESPOND:
|
||||
for (i = 0; i < db->urlcount; i++)
|
||||
{
|
||||
/* check size limitation */
|
||||
- if (truncate && result->curpos - result->start > truncate)
|
||||
+ if (result->curpos - result->start >= size)
|
||||
+ {
|
||||
+ /* reached size limit due to truncation. fix up url count */
|
||||
+ TO_UINT16(result->start + 14 + message->header.langtaglen + 2, i);
|
||||
break;
|
||||
+ }
|
||||
|
||||
/* urlentry is the url from the db result */
|
||||
urlentry = db->urlarray[i];
|
||||
@@ -880,10 +896,12 @@ static int ProcessSrvAck(SLPMessage * me
|
||||
* @internal
|
||||
*/
|
||||
static int ProcessAttrRqst(SLPMessage * message, SLPBuffer * sendbuf,
|
||||
- int errorcode)
|
||||
+ int errorcode, int truncate)
|
||||
{
|
||||
SLPDDatabaseAttrRqstResult * db = 0;
|
||||
size_t size = 0;
|
||||
+ int truncated = 1;
|
||||
+ size_t attrlistlen = 0;
|
||||
SLPBuffer result = *sendbuf;
|
||||
|
||||
#ifdef ENABLE_SLPv2_SECURITY
|
||||
@@ -1032,6 +1050,15 @@ RESPOND:
|
||||
}
|
||||
#endif
|
||||
|
||||
+ /* truncate if needed */
|
||||
+ attrlistlen = db->attrlistlen;
|
||||
+ if (truncate && size > truncate && G_SlpdProperty.hardMTU)
|
||||
+ {
|
||||
+ attrlistlen = 0;
|
||||
+ opaqueauth = 0;
|
||||
+ size = message->header.langtaglen + 19; /* 14 bytes for header */
|
||||
+ truncated = 1;
|
||||
+ }
|
||||
}
|
||||
|
||||
/* alloc the buffer */
|
||||
@@ -1054,7 +1081,7 @@ RESPOND:
|
||||
PutUINT24(&result->curpos, size);
|
||||
|
||||
/* flags */
|
||||
- PutUINT16(&result->curpos, (size > (size_t)G_SlpdProperty.MTU?
|
||||
+ PutUINT16(&result->curpos, (truncated || size > (size_t)G_SlpdProperty.MTU?
|
||||
SLP_FLAG_OVERFLOW: 0));
|
||||
|
||||
/* ext offset */
|
||||
@@ -1078,10 +1105,10 @@ RESPOND:
|
||||
if (errorcode == 0)
|
||||
{
|
||||
/* attr-list len */
|
||||
- PutUINT16(&result->curpos, db->attrlistlen);
|
||||
- if (db->attrlistlen)
|
||||
- memcpy(result->curpos, db->attrlist, db->attrlistlen);
|
||||
- result->curpos += db->attrlistlen;
|
||||
+ PutUINT16(&result->curpos, attrlistlen);
|
||||
+ if (attrlistlen)
|
||||
+ memcpy(result->curpos, db->attrlist, attrlistlen);
|
||||
+ result->curpos += attrlistlen;
|
||||
|
||||
/* authentication block */
|
||||
#ifdef ENABLE_SLPv2_SECURITY
|
||||
@@ -1187,9 +1214,11 @@ RESPOND:
|
||||
* @internal
|
||||
*/
|
||||
static int ProcessSrvTypeRqst(SLPMessage * message, SLPBuffer * sendbuf,
|
||||
- int errorcode)
|
||||
+ int errorcode, int truncate)
|
||||
{
|
||||
size_t size = 0;
|
||||
+ int truncated = 0;
|
||||
+ size_t typelistlen = 0;
|
||||
SLPDDatabaseSrvTypeRqstResult * db = 0;
|
||||
SLPBuffer result = *sendbuf;
|
||||
|
||||
@@ -1233,7 +1262,18 @@ RESPOND:
|
||||
/* 2 bytes for error code */
|
||||
/* 2 bytes for srvtype len */
|
||||
if (errorcode == 0)
|
||||
+ {
|
||||
size += db->srvtypelistlen;
|
||||
+ typelistlen = db->srvtypelistlen;
|
||||
+
|
||||
+ /* truncate result if needed */
|
||||
+ if (truncate && size > truncate && G_SlpdProperty.hardMTU)
|
||||
+ {
|
||||
+ typelistlen = 0;
|
||||
+ size -= db->srvtypelistlen;
|
||||
+ truncated = 1;
|
||||
+ }
|
||||
+ }
|
||||
|
||||
/* Reallocate the result buffer */
|
||||
result = SLPBufferRealloc(result, size);
|
||||
@@ -1255,7 +1295,7 @@ RESPOND:
|
||||
PutUINT24(&result->curpos, size);
|
||||
|
||||
/* flags */
|
||||
- PutUINT16(&result->curpos, (size > (size_t)G_SlpdProperty.MTU?
|
||||
+ PutUINT16(&result->curpos, (truncated || size > (size_t)G_SlpdProperty.MTU?
|
||||
SLP_FLAG_OVERFLOW: 0));
|
||||
|
||||
/* ext offset */
|
||||
@@ -1279,9 +1319,10 @@ RESPOND:
|
||||
if (errorcode == 0)
|
||||
{
|
||||
/* length of srvtype-list */
|
||||
- PutUINT16(&result->curpos, db->srvtypelistlen);
|
||||
- memcpy(result->curpos, db->srvtypelist, db->srvtypelistlen);
|
||||
- result->curpos += db->srvtypelistlen;
|
||||
+ PutUINT16(&result->curpos, typelistlen);
|
||||
+ if (typelistlen)
|
||||
+ memcpy(result->curpos, db->srvtypelist, typelistlen);
|
||||
+ result->curpos += typelistlen;
|
||||
}
|
||||
|
||||
FINISHED:
|
||||
@@ -1412,7 +1453,7 @@ int SLPDProcessMessage(struct sockaddr_s
|
||||
break;
|
||||
|
||||
case SLP_FUNCT_ATTRRQST:
|
||||
- errorcode = ProcessAttrRqst(message, sendbuf, errorcode);
|
||||
+ errorcode = ProcessAttrRqst(message, sendbuf, errorcode, truncate);
|
||||
break;
|
||||
|
||||
case SLP_FUNCT_DAADVERT:
|
||||
@@ -1421,7 +1462,7 @@ int SLPDProcessMessage(struct sockaddr_s
|
||||
break;
|
||||
|
||||
case SLP_FUNCT_SRVTYPERQST:
|
||||
- errorcode = ProcessSrvTypeRqst(message, sendbuf, errorcode);
|
||||
+ errorcode = ProcessSrvTypeRqst(message, sendbuf, errorcode, truncate);
|
||||
break;
|
||||
|
||||
case SLP_FUNCT_SAADVERT:
|
||||
--- ./slpd/slpd_property.c.orig 2014-02-18 17:14:52.112092941 +0000
|
||||
+++ ./slpd/slpd_property.c 2014-02-18 17:15:01.465092925 +0000
|
||||
@@ -250,6 +250,8 @@ void SLPDPropertyReinit(void)
|
||||
G_SlpdProperty.myHostname = SLPDGetCanonHostname();
|
||||
G_SlpdProperty.myHostnameLen = strlen(G_SlpdProperty.myHostname);
|
||||
|
||||
+ G_SlpdProperty.hardMTU = SLPPropertyAsBoolean("net.slp.hardMTU");
|
||||
+
|
||||
G_SlpdProperty.DASyncReg = SLPPropertyAsBoolean("net.slp.DASyncReg");
|
||||
G_SlpdProperty.isDABackup = SLPPropertyAsBoolean("net.slp.isDABackup");
|
||||
G_SlpdProperty.DABackupInterval = SLPPropertyAsInteger("net.slp.DABackupInterval");
|
||||
--- ./slpd/slpd_property.h.orig 2014-02-18 17:14:52.113092941 +0000
|
||||
+++ ./slpd/slpd_property.h 2014-02-18 17:15:01.465092925 +0000
|
||||
@@ -117,6 +117,7 @@ typedef struct _SLPDProperty
|
||||
int MTU;
|
||||
int useDHCP;
|
||||
int oversizedUDP;
|
||||
+ int hardMTU;
|
||||
|
||||
int DASyncReg;
|
||||
int isDABackup;
|
@ -1,19 +0,0 @@
|
||||
--- common/slp_compare.c.orig 2010-10-01 11:17:13.000000000 +0000
|
||||
+++ common/slp_compare.c 2010-10-01 11:26:52.000000000 +0000
|
||||
@@ -105,6 +105,16 @@ int SLPCompareString(int str1len,
|
||||
/* <0 if s1 is less than str2 */
|
||||
/*=========================================================================*/
|
||||
{
|
||||
+ /* strip leading/trailing while space */
|
||||
+ while (str1len && (*str1 == ' ' || *str1 == '\t' || *str1 == '\r' || *str1 == '\n'))
|
||||
+ str1++, str1len--;
|
||||
+ while (str1len && (str1[str1len - 1] == ' ' || str1[str1len - 1] == '\t' || str1[str1len - 1] == '\r' || str1[str1len - 1] == '\n'))
|
||||
+ str1len--;
|
||||
+ while (str2len && (*str2 == ' ' || *str2 == '\t' || *str2 == '\r' || *str2 == '\n'))
|
||||
+ str2++, str2len--;
|
||||
+ while (str2len && (str2[str2len - 1] == ' ' || str2[str2len - 1] == '\t' || str2[str2len - 1] == '\r' || str2[str2len - 1] == '\n'))
|
||||
+ str2len--;
|
||||
+
|
||||
/* TODO: fold whitespace and handle escapes*/
|
||||
if(str1len == str2len)
|
||||
{
|
1185
openslp.initda.diff
1185
openslp.initda.diff
File diff suppressed because it is too large
Load Diff
13
openslp.localtime.diff
Normal file
13
openslp.localtime.diff
Normal file
@ -0,0 +1,13 @@
|
||||
--- ./slpd/slpd_log.c.orig 2014-02-19 17:30:21.682938372 +0000
|
||||
+++ ./slpd/slpd_log.c 2014-02-19 17:32:04.664938189 +0000
|
||||
@@ -182,7 +182,9 @@ void SLPDLogBuffer(const char * prefix,
|
||||
void SLPDLogTime(void)
|
||||
{
|
||||
time_t curtime = time(0);
|
||||
- SLPDLog("%s", ctime(&curtime));
|
||||
+ struct tm ltm;
|
||||
+ /* we use localtime_r so that glibc does not re-init the timezone */
|
||||
+ SLPDLog("%s", asctime(localtime_r(&curtime, <m)));
|
||||
}
|
||||
|
||||
/** Logs information about a SrvRequest message to the log file.
|
214
openslp.netlink.diff
Normal file
214
openslp.netlink.diff
Normal file
@ -0,0 +1,214 @@
|
||||
--- ./slpd/slpd_database.c.orig 2014-02-19 18:04:09.926934782 +0000
|
||||
+++ ./slpd/slpd_database.c 2014-02-19 18:04:34.553934738 +0000
|
||||
@@ -50,6 +50,10 @@
|
||||
#define _GNU_SOURCE
|
||||
#include <string.h>
|
||||
#include <dirent.h>
|
||||
+#include <sys/socket.h>
|
||||
+#include <linux/netlink.h>
|
||||
+#include <linux/inet_diag.h>
|
||||
+#include <sched.h>
|
||||
|
||||
#include "../libslpattr/libslpattr.h"
|
||||
#include "slpd_database.h"
|
||||
@@ -1919,6 +1923,168 @@ int SLPDDatabaseReInit()
|
||||
return 0;
|
||||
}
|
||||
|
||||
+enum {
|
||||
+ SS_UNKNOWN,
|
||||
+ SS_ESTABLISHED,
|
||||
+ SS_SYN_SENT,
|
||||
+ SS_SYN_RECV,
|
||||
+ SS_FIN_WAIT1,
|
||||
+ SS_FIN_WAIT2,
|
||||
+ SS_TIME_WAIT,
|
||||
+ SS_CLOSE,
|
||||
+ SS_CLOSE_WAIT,
|
||||
+ SS_LAST_ACK,
|
||||
+ SS_LISTEN,
|
||||
+ SS_CLOSING,
|
||||
+ SS_MAX
|
||||
+};
|
||||
+
|
||||
+#define SS_ALL ((1<<SS_MAX)-1)
|
||||
+
|
||||
+static int reconnect_nl(int *fd)
|
||||
+{
|
||||
+ int new_fd = socket(AF_NETLINK, SOCK_RAW, NETLINK_INET_DIAG);
|
||||
+ close (*fd);
|
||||
+ if (new_fd < 0)
|
||||
+ return errno;
|
||||
+ *fd = new_fd;
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
+static void SLPDDatabaseWatcher_nl(int *fd, int flag, unsigned char *porthash)
|
||||
+{
|
||||
+ char buf[8192];
|
||||
+ int port, status = 0;
|
||||
+ SLPDatabaseHandle dh;
|
||||
+
|
||||
+ struct sockaddr_nl nladdr = {
|
||||
+ .nl_family = AF_NETLINK
|
||||
+ };
|
||||
+
|
||||
+ struct {
|
||||
+ struct nlmsghdr nlh;
|
||||
+ struct inet_diag_req r;
|
||||
+ } req = {
|
||||
+ .nlh = {
|
||||
+ .nlmsg_len = sizeof(req),
|
||||
+ .nlmsg_type = TCPDIAG_GETSOCK,
|
||||
+ .nlmsg_flags = NLM_F_ROOT|NLM_F_MATCH|NLM_F_REQUEST,
|
||||
+ .nlmsg_pid = 0,
|
||||
+ .nlmsg_seq = 123456,
|
||||
+ },
|
||||
+ .r = {
|
||||
+ .idiag_family = AF_INET,
|
||||
+ .idiag_states = 1 << SS_LISTEN,
|
||||
+ .idiag_ext = ((1 << (INET_DIAG_INFO - 1)) |
|
||||
+ (1 << (INET_DIAG_VEGASINFO - 1)) |
|
||||
+ (1 << (INET_DIAG_CONG - 1))),
|
||||
+ }
|
||||
+ };
|
||||
+
|
||||
+ struct iovec iov = {
|
||||
+ .iov_base = &req,
|
||||
+ .iov_len = sizeof(req),
|
||||
+ };
|
||||
+
|
||||
+ struct msghdr msg = {
|
||||
+ .msg_name = (void *)&nladdr,
|
||||
+ .msg_namelen = sizeof(nladdr),
|
||||
+ .msg_iov = &iov,
|
||||
+ .msg_iovlen = 1,
|
||||
+ };
|
||||
+ struct in_addr ipv4_loopback = { htonl(INADDR_LOOPBACK) };
|
||||
+ struct in6_addr ipv6_loopback = IN6ADDR_LOOPBACK_INIT;
|
||||
+ int retries;
|
||||
+
|
||||
+ /* If the socket shuts down for whatever reason, we need to
|
||||
+ * reopen it. Since we can't listen to a socket for which we have
|
||||
+ * made a request, we reissue the request and listen again. */
|
||||
+retry_sendmsg:
|
||||
+ retries = 2;
|
||||
+ while (retries-- > 0) {
|
||||
+ if (sendmsg(*fd, &msg, 0) >= 0)
|
||||
+ break;
|
||||
+
|
||||
+ if (reconnect_nl(fd)) {
|
||||
+ SLPDLog("Lost TCPDIAG netlink connection and attempts to "
|
||||
+ "re-establish have failed. Falling back to /proc/net/tcp "
|
||||
+ "for dead/alive updates.\n");
|
||||
+ *fd = -1;
|
||||
+ return;
|
||||
+ }
|
||||
+ sched_yield();
|
||||
+ }
|
||||
+
|
||||
+ iov.iov_base = buf;
|
||||
+ iov.iov_len = sizeof(buf);
|
||||
+
|
||||
+ dh = SLPDatabaseOpen(&G_SlpdDatabase.database);
|
||||
+ while (!status) {
|
||||
+ struct nlmsghdr *h;
|
||||
+
|
||||
+ status = recvmsg(*fd, &msg, 0);
|
||||
+ if (status < 0) {
|
||||
+ if (errno == EINTR)
|
||||
+ continue;
|
||||
+ goto retry_sendmsg;
|
||||
+ }
|
||||
+
|
||||
+ /* Socket has shut down */
|
||||
+ if (status == 0)
|
||||
+ goto retry_sendmsg;
|
||||
+
|
||||
+ for (h = (struct nlmsghdr *) buf; NLMSG_OK(h, status);
|
||||
+ h = NLMSG_NEXT(h, status)) {
|
||||
+ SLPDatabaseEntry *entry;
|
||||
+ struct inet_diag_msg *r = NLMSG_DATA(h);
|
||||
+
|
||||
+ if (h->nlmsg_seq != 123456)
|
||||
+ continue;
|
||||
+
|
||||
+ if (h->nlmsg_type == NLMSG_DONE)
|
||||
+ goto close;
|
||||
+
|
||||
+ if (h->nlmsg_type == NLMSG_ERROR) {
|
||||
+ struct nlmsgerr *err = NLMSG_DATA(h);
|
||||
+ if (h->nlmsg_len >= NLMSG_LENGTH(sizeof(*err)))
|
||||
+ status = EINVAL;
|
||||
+ else
|
||||
+ status = -err->error;
|
||||
+ break;
|
||||
+ }
|
||||
+
|
||||
+ if (r->idiag_family != AF_INET && r->idiag_family != AF_INET6)
|
||||
+ continue;
|
||||
+
|
||||
+ if (r->idiag_family == AF_INET &&
|
||||
+ ipv4_loopback.s_addr == r->id.idiag_src[0])
|
||||
+ continue;
|
||||
+
|
||||
+ if (r->idiag_family == AF_INET6 &&
|
||||
+ !memcmp(ipv6_loopback.s6_addr32, r->id.idiag_src,
|
||||
+ sizeof(ipv6_loopback)))
|
||||
+ continue;
|
||||
+
|
||||
+ port = ntohs(r->id.idiag_sport);
|
||||
+ if (!(porthash[(port / 8) & 255] & (1 << (port & 7))))
|
||||
+ continue;
|
||||
+
|
||||
+ SLPDatabaseRewind(dh);
|
||||
+
|
||||
+ while ((entry = SLPDatabaseEnum(dh)) != 0) {
|
||||
+ SLPSrvReg *srvreg = &(entry->msg->body.srvreg);
|
||||
+ if (!(srvreg->watchflags & flag))
|
||||
+ continue;
|
||||
+ if (port == srvreg->watchport)
|
||||
+ srvreg->watchflags &= ~SLP_REG_WATCH_CHECKING;
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+close:
|
||||
+ SLPDatabaseClose(dh);
|
||||
+}
|
||||
+
|
||||
static void SLPDDatabaseWatcher_fd(int fd, int flag, unsigned char *porthash)
|
||||
{
|
||||
SLPDatabaseHandle dh;
|
||||
@@ -1978,7 +2144,7 @@ static void SLPDDatabaseWatcher_fd(int f
|
||||
void SLPDDatabaseWatcher(void)
|
||||
{
|
||||
static int initialized = 0;
|
||||
- static int proctcp, procudp, proctcp6, procudp6;
|
||||
+ static int proctcp, procudp, proctcp6, procudp6, inet_diag = -1;
|
||||
unsigned char porthash[256];
|
||||
int flags, port;
|
||||
SLPDatabaseHandle dh;
|
||||
@@ -1986,6 +2152,7 @@ void SLPDDatabaseWatcher(void)
|
||||
SLPSrvReg* srvreg;
|
||||
|
||||
if (!initialized) {
|
||||
+ inet_diag = socket(AF_NETLINK, SOCK_RAW, NETLINK_INET_DIAG);
|
||||
proctcp = open("/proc/net/tcp_listen", O_RDONLY);
|
||||
if (proctcp == -1)
|
||||
proctcp = open("/proc/net/tcp", O_RDONLY);
|
||||
@@ -2010,8 +2177,12 @@ void SLPDDatabaseWatcher(void)
|
||||
}
|
||||
SLPDatabaseClose(dh);
|
||||
if ((flags & SLP_REG_WATCH_TCP) != 0) {
|
||||
- SLPDDatabaseWatcher_fd(proctcp, SLP_REG_WATCH_TCP, porthash);
|
||||
- SLPDDatabaseWatcher_fd(proctcp6, SLP_REG_WATCH_TCP, porthash);
|
||||
+ if (inet_diag >= 0)
|
||||
+ SLPDDatabaseWatcher_nl(&inet_diag, SLP_REG_WATCH_TCP, porthash);
|
||||
+ if (inet_diag < 0) { /* Fallback if _nl fails */
|
||||
+ SLPDDatabaseWatcher_fd(proctcp, SLP_REG_WATCH_TCP, porthash);
|
||||
+ SLPDDatabaseWatcher_fd(proctcp6, SLP_REG_WATCH_TCP, porthash);
|
||||
+ }
|
||||
}
|
||||
if ((flags & SLP_REG_WATCH_UDP) != 0) {
|
||||
SLPDDatabaseWatcher_fd(procudp, SLP_REG_WATCH_UDP, porthash);
|
@ -1,22 +0,0 @@
|
||||
--- ./common/slp_message.c.orig 2010-10-12 15:42:23.439823000 +0000
|
||||
+++ ./common/slp_message.c 2010-10-12 15:45:44.936750000 +0000
|
||||
@@ -872,10 +872,19 @@ int ParseExtension(SLPBuffer buffer, SLP
|
||||
int extid;
|
||||
int nextoffset;
|
||||
int result = SLP_ERROR_OK;
|
||||
+ int bufsz = (int)(buffer->end - buffer->start);
|
||||
|
||||
nextoffset = message->header.extoffset;
|
||||
while(nextoffset)
|
||||
{
|
||||
+ /* check for circular reference in list
|
||||
+ * if the size gets below zero, we know we're
|
||||
+ * reprocessing extensions in a loop.
|
||||
+ */
|
||||
+ bufsz -= 5;
|
||||
+ if (bufsz <= 0)
|
||||
+ return SLP_ERROR_PARSE_ERROR;
|
||||
+
|
||||
buffer->curpos = buffer->start + nextoffset;
|
||||
if(buffer->curpos + 5 >= buffer->end)
|
||||
{
|
@ -1,853 +0,0 @@
|
||||
--- ./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);
|
||||
}
|
||||
|
||||
/*----------------*/
|
66
openslp.spec
66
openslp.spec
@ -1,7 +1,7 @@
|
||||
#
|
||||
# spec file for package openslp
|
||||
#
|
||||
# Copyright (c) 2013 SUSE LINUX Products GmbH, Nuernberg, Germany.
|
||||
# Copyright (c) 2014 SUSE LINUX Products GmbH, Nuernberg, Germany.
|
||||
#
|
||||
# All modifications and additions to the file contributed by third parties
|
||||
# remain the property of their copyright owners, unless otherwise agreed
|
||||
@ -28,7 +28,7 @@ BuildRequires: pkgconfig(systemd)
|
||||
Summary: An OpenSLP Implementation of Service Location Protocol V2
|
||||
License: BSD-3-Clause
|
||||
Group: System/Daemons
|
||||
Version: 1.2.0
|
||||
Version: 2.0.0
|
||||
Release: 0
|
||||
Url: http://www.openslp.org/
|
||||
# bug437293
|
||||
@ -37,9 +37,9 @@ Obsoletes: openslp-64bit
|
||||
%endif
|
||||
#
|
||||
BuildRoot: %{_tmppath}/%{name}-%{version}-build
|
||||
Source0: http://sourceforge.net/projects/openslp/files/OpenSLP/%{version}/%name-%version.tar.gz
|
||||
Source0: http://sourceforge.net/projects/openslp/files/2.0.0/%{version}/%name-%version.tar.gz
|
||||
Source1: slpd.init
|
||||
Source2: README.SuSE
|
||||
Source2: README.SUSE
|
||||
Source3: openslp.desktop
|
||||
Source4: openslp-devel.desktop
|
||||
Source5: openslp.logrotate
|
||||
@ -47,31 +47,17 @@ Source6: slpd.xml
|
||||
Source7: openslp.SuSEfirewall2
|
||||
Source8: baselibs.conf
|
||||
Source9: slpd.service
|
||||
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
|
||||
Patch14: openslp.dereg.diff
|
||||
Patch15: openslp.fixaddrcheck.diff
|
||||
Patch16: openslp.fixdsareturn.diff
|
||||
Patch17: openslp.clrflags.diff
|
||||
Patch18: openslp.use-TCPDIAG-for-checking-listeners
|
||||
Patch19: openslp.discovery.diff
|
||||
Patch20: openslp.initda.diff
|
||||
Patch21: openslp.ignorespaces.diff
|
||||
Patch22: openslp.parseext.diff
|
||||
Patch23: openslp-1.2.0-visibility.patch
|
||||
Patch24: openslp-1.2.0-daemon.diff
|
||||
Patch25: openslp-ocloexec.patch
|
||||
Patch1: openslp.audit.diff
|
||||
Patch2: extensions.diff
|
||||
Patch3: openslp.truncate.diff
|
||||
Patch4: openslp.netlink.diff
|
||||
Patch5: openslp.initda.diff
|
||||
Patch6: openslp.visibility.diff
|
||||
Patch7: openslp.daemon.diff
|
||||
Patch8: openslp.cloexec.diff
|
||||
Patch9: openslp.hardmtu.diff
|
||||
Patch10: openslp.tcplocal.diff
|
||||
Patch11: openslp.localtime.diff
|
||||
|
||||
%description
|
||||
Service Location Protocol is an IETF standards track protocol that
|
||||
@ -129,29 +115,13 @@ such applications.
|
||||
%patch2
|
||||
%patch3
|
||||
%patch4
|
||||
%ifarch hppa
|
||||
%patch5
|
||||
%endif
|
||||
%patch6
|
||||
%patch7
|
||||
%patch8
|
||||
%patch9
|
||||
%patch10
|
||||
%patch11
|
||||
%patch12
|
||||
%patch13
|
||||
%patch14
|
||||
%patch15
|
||||
%patch16
|
||||
%patch17
|
||||
%patch18 -p1
|
||||
%patch19
|
||||
%patch20
|
||||
%patch21
|
||||
%patch22
|
||||
%patch23
|
||||
%patch24 -p1
|
||||
%patch25
|
||||
|
||||
%build
|
||||
autoreconf -fiv
|
||||
@ -176,7 +146,7 @@ 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 \
|
||||
cp -a AUTHORS COPYING README FAQ doc/doc/rfc doc/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
|
||||
@ -208,7 +178,7 @@ install -D -m 644 %{S:9} %{buildroot}%{_unitdir}/slpd.service
|
||||
%endif
|
||||
|
||||
#XXX test suite requires root
|
||||
#%check
|
||||
#check
|
||||
#make check
|
||||
|
||||
%post -p /sbin/ldconfig
|
||||
@ -251,7 +221,7 @@ install -D -m 644 %{S:9} %{buildroot}%{_unitdir}/slpd.service
|
||||
%doc %_defaultdocdir/%name/AUTHORS
|
||||
%doc %_defaultdocdir/%name/COPYING
|
||||
%doc %_defaultdocdir/%name/README
|
||||
%doc %_defaultdocdir/%name/README.SuSE
|
||||
%doc %_defaultdocdir/%name/README.SUSE
|
||||
%_libdir/libslp.so.*
|
||||
/usr/bin/slptool
|
||||
%config(noreplace) /etc/slp.conf
|
||||
|
@ -1,27 +0,0 @@
|
||||
--- ./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);
|
||||
}
|
106
openslp.tcplocal.diff
Normal file
106
openslp.tcplocal.diff
Normal file
@ -0,0 +1,106 @@
|
||||
--- ./libslp/libslp_findattrs.c.orig 2014-02-20 10:41:46.070828839 +0000
|
||||
+++ ./libslp/libslp_findattrs.c 2014-02-20 10:42:44.604828735 +0000
|
||||
@@ -220,7 +220,7 @@ static SLPError ProcessAttrRqst(SLPHandl
|
||||
curpos - buf, ProcessAttrRplyCallback, handle, isV1);
|
||||
break;
|
||||
}
|
||||
- if (SLPNetIsIPV4())
|
||||
+ if (SLPNetIsIPV4() && handle->params.findattrs.scopelistlen && memchr(handle->params.findattrs.scopelist, ',', handle->params.findattrs.scopelistlen))
|
||||
{
|
||||
if (KnownDASpanningListFromCache(handle,
|
||||
(int)handle->params.findattrs.scopelistlen,
|
||||
--- ./libslp/libslp_findsrvs.c.orig 2014-02-20 10:41:51.558828829 +0000
|
||||
+++ ./libslp/libslp_findsrvs.c 2014-02-20 10:43:06.068828697 +0000
|
||||
@@ -352,7 +352,7 @@ static SLPError ProcessSrvRqst(SLPHandle
|
||||
curpos - buf, ProcessSrvRplyCallback, handle, false);
|
||||
break;
|
||||
}
|
||||
- if (SLPNetIsIPV4())
|
||||
+ if (SLPNetIsIPV4() && handle->params.findsrvs.scopelistlen && memchr(handle->params.findsrvs.scopelist, ',', handle->params.findsrvs.scopelistlen))
|
||||
{
|
||||
if (KnownDASpanningListFromCache(handle,
|
||||
(int)handle->params.findsrvs.scopelistlen,
|
||||
--- ./libslp/libslp_findsrvtypes.c.orig 2014-02-20 10:41:55.765828821 +0000
|
||||
+++ ./libslp/libslp_findsrvtypes.c 2014-02-20 10:44:10.708828583 +0000
|
||||
@@ -238,11 +238,11 @@ static SLPError ProcessSrvTypeRqst(SLPHa
|
||||
curpos - buf, ProcessSrvTypeRplyCallback, handle, false);
|
||||
break;
|
||||
}
|
||||
- if (SLPNetIsIPV4())
|
||||
+ if (SLPNetIsIPV4() && handle->params.findsrvtypes.scopelistlen && memchr(handle->params.findsrvtypes.scopelist, ',', handle->params.findsrvtypes.scopelistlen))
|
||||
{
|
||||
if (KnownDASpanningListFromCache(handle,
|
||||
- (int)handle->params.findsrvs.scopelistlen,
|
||||
- handle->params.findsrvs.scopelist,
|
||||
+ (int)handle->params.findsrvtypes.scopelistlen,
|
||||
+ handle->params.findsrvtypes.scopelist,
|
||||
&destaddrs) > 0)
|
||||
{
|
||||
serr = NetworkMultiUcastRqstRply(destaddrs,
|
||||
--- ./libslp/libslp_knownda.c.orig 2012-12-12 17:38:52.000000000 +0000
|
||||
+++ ./libslp/libslp_knownda.c 2014-02-20 10:40:19.448828992 +0000
|
||||
@@ -793,6 +793,8 @@ sockfd_t KnownDAConnect(SLPHandleInfo *
|
||||
const char * scopelist, void * peeraddr)
|
||||
{
|
||||
sockfd_t sock = SLP_INVALID_SOCKET;
|
||||
+ int maxwait = SLPPropertyAsInteger("net.slp.DADiscoveryMaximumWait");
|
||||
+ struct timeval timeout;
|
||||
size_t spistrlen = 0;
|
||||
char * spistr = 0;
|
||||
|
||||
@@ -815,15 +817,11 @@ sockfd_t KnownDAConnect(SLPHandleInfo *
|
||||
|| (addr->sa_family == AF_INET && SLPNetIsIPV4()))
|
||||
{
|
||||
SLPNetSetPort(peeraddr, (uint16_t)SLPPropertyAsInteger("net.slp.port"));
|
||||
- sock = SLPNetworkCreateDatagram(addr->sa_family);
|
||||
- /* Now test if the DA will actually respond */
|
||||
+ timeout.tv_usec = (maxwait % 1000) * 1000;
|
||||
+ timeout.tv_sec = maxwait / 1000;
|
||||
+ sock = SLPNetworkConnectStream(addr, &timeout);
|
||||
if (sock != SLP_INVALID_SOCKET)
|
||||
- {
|
||||
- if (KnownDADiscoveryRqstRply(sock, peeraddr, scopelistlen, scopelist, handle) > 0)
|
||||
- break;
|
||||
-
|
||||
- closesocket(sock);
|
||||
- }
|
||||
+ break;
|
||||
}
|
||||
KnownDABadDA(peeraddr);
|
||||
}
|
||||
--- ./libslp/libslp_network.c.orig 2014-02-20 10:40:15.262828999 +0000
|
||||
+++ ./libslp/libslp_network.c 2014-02-20 10:40:19.449828992 +0000
|
||||
@@ -370,6 +370,8 @@ static int NetworkGetMcastAddrs(const ch
|
||||
sockfd_t NetworkConnectToSlpd(void * peeraddr)
|
||||
{
|
||||
sockfd_t sock = SLP_INVALID_SOCKET;
|
||||
+ int maxwait = SLPPropertyAsInteger("net.slp.DADiscoveryMaximumWait");
|
||||
+ struct timeval timeout;
|
||||
|
||||
/*Note that these don't actually test the connection to slpd.
|
||||
They don't have to, since all code that calls this function eventually
|
||||
@@ -378,14 +380,22 @@ sockfd_t NetworkConnectToSlpd(void * pee
|
||||
if (SLPNetIsIPV6())
|
||||
if (!SLPNetSetAddr(peeraddr, AF_INET6, (uint16_t)SLPPropertyAsInteger("net.slp.port"),
|
||||
&slp_in6addr_loopback))
|
||||
- sock = SLPNetworkCreateDatagram(AF_INET6);
|
||||
+ {
|
||||
+ timeout.tv_sec = maxwait / 1000;
|
||||
+ timeout.tv_usec = (maxwait % 1000) * 1000;
|
||||
+ sock = SLPNetworkConnectStream(peeraddr, &timeout);
|
||||
+ }
|
||||
|
||||
if (sock == SLP_INVALID_SOCKET && SLPNetIsIPV4())
|
||||
{
|
||||
int tempAddr = INADDR_LOOPBACK;
|
||||
if (SLPNetSetAddr(peeraddr, AF_INET,
|
||||
(uint16_t)SLPPropertyAsInteger("net.slp.port"), &tempAddr) == 0)
|
||||
- sock = SLPNetworkCreateDatagram(AF_INET);
|
||||
+ {
|
||||
+ timeout.tv_sec = maxwait / 1000;
|
||||
+ timeout.tv_usec = (maxwait % 1000) * 1000;
|
||||
+ sock = SLPNetworkConnectStream(peeraddr, &timeout);
|
||||
+ }
|
||||
}
|
||||
return sock;
|
||||
}
|
@ -1,71 +1,75 @@
|
||||
--- ./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);
|
||||
--- ./slpd/slpd_incoming.c.orig 2014-02-14 14:41:40.468720908 +0000
|
||||
+++ ./slpd/slpd_incoming.c 2014-02-14 14:49:02.307720126 +0000
|
||||
@@ -75,6 +75,7 @@ static void IncomingDatagramRead(SLPList
|
||||
socklen_t peeraddrlen = sizeof(struct sockaddr_storage);
|
||||
char addr_str[INET6_ADDRSTRLEN];
|
||||
sockfd_t sendsock = SLP_INVALID_SOCKET;
|
||||
+ int truncate;
|
||||
|
||||
bytesread = recvfrom(sock->fd,
|
||||
sock->recvbuf->start,
|
||||
@@ -90,9 +91,13 @@ void IncomingDatagramRead(SLPList* sockl
|
||||
(void)socklist;
|
||||
|
||||
@@ -85,6 +86,10 @@ static void IncomingDatagramRead(SLPList
|
||||
{
|
||||
sock->recvbuf->end = sock->recvbuf->start + bytesread;
|
||||
|
||||
+ truncate = SLP_MAX_DATAGRAM_SIZE;
|
||||
+ truncate = G_SlpdProperty.MTU;
|
||||
+ 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
|
||||
+
|
||||
if (!sock->sendbuf)
|
||||
/* Some of the error handling code expects a sendbuf to be available
|
||||
* to be emptied, so make sure there is at least a minimal buffer
|
||||
@@ -92,7 +97,7 @@ static void IncomingDatagramRead(SLPList
|
||||
sock->sendbuf = SLPBufferAlloc(1);
|
||||
|
||||
SLPDProcessMessage(&(sock->peeraddr),
|
||||
sock->recvbuf,
|
||||
- &(sock->sendbuf));
|
||||
+ &(sock->sendbuf), 0);
|
||||
switch (SLPDProcessMessage(&sock->peeraddr, &sock->localaddr,
|
||||
- sock->recvbuf, &sock->sendbuf, 0))
|
||||
+ sock->recvbuf, &sock->sendbuf, 0, truncate))
|
||||
{
|
||||
case SLP_ERROR_PARSE_ERROR:
|
||||
case SLP_ERROR_VER_NOT_SUPPORTED:
|
||||
@@ -281,7 +286,7 @@ static void IncomingStreamRead(SLPList *
|
||||
*/
|
||||
sock->sendbuf = SLPBufferAlloc(1);
|
||||
switch (SLPDProcessMessage(&sock->peeraddr,
|
||||
- &sock->localaddr, sock->recvbuf, &sock->sendbuf, 0))
|
||||
+ &sock->localaddr, sock->recvbuf, &sock->sendbuf, 0, 0))
|
||||
{
|
||||
case SLP_ERROR_PARSE_ERROR:
|
||||
case SLP_ERROR_VER_NOT_SUPPORTED:
|
||||
--- ./slpd/slpd_outgoing.c.orig 2014-02-14 14:41:33.205720921 +0000
|
||||
+++ ./slpd/slpd_outgoing.c 2014-02-14 14:49:31.691720074 +0000
|
||||
@@ -77,7 +77,7 @@ void OutgoingDatagramRead(SLPList * sock
|
||||
*/
|
||||
sock->sendbuf = SLPBufferAlloc(1);
|
||||
SLPDProcessMessage(&sock->peeraddr, &sock->localaddr,
|
||||
- sock->recvbuf, &sock->sendbuf, &sock->sendlist);
|
||||
+ sock->recvbuf, &sock->sendbuf, &sock->sendlist, 0);
|
||||
|
||||
/* Completely ignore the message */
|
||||
}
|
||||
@@ -264,7 +264,7 @@ void OutgoingStreamRead(SLPList* socklis
|
||||
{
|
||||
switch ( SLPDProcessMessage(&(sock->peeraddr),
|
||||
sock->recvbuf,
|
||||
- &(sock->sendbuf)) )
|
||||
+ &(sock->sendbuf), 0) )
|
||||
|
||||
@@ -267,7 +267,7 @@ void OutgoingStreamRead(SLPList * sockli
|
||||
/* check to see if everything was read */
|
||||
if (sock->recvbuf->curpos == sock->recvbuf->end)
|
||||
switch (SLPDProcessMessage(&(sock->peeraddr), &(sock->localaddr),
|
||||
- sock->recvbuf, &(sock->sendbuf), 0))
|
||||
+ sock->recvbuf, &(sock->sendbuf), 0, 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,
|
||||
--- ./slpd/slpd_process.c.orig 2014-02-14 14:31:18.532722009 +0000
|
||||
+++ ./slpd/slpd_process.c 2014-02-14 14:39:14.059721168 +0000
|
||||
@@ -400,7 +400,7 @@ static int ProcessDASrvRqst(SLPMessage *
|
||||
* @internal
|
||||
*/
|
||||
static int ProcessSrvRqst(SLPMessage * message, SLPBuffer * sendbuf,
|
||||
- int errorcode)
|
||||
+ int errorcode,
|
||||
+ int truncate)
|
||||
/*-------------------------------------------------------------------------*/
|
||||
+ int errorcode, int truncate)
|
||||
{
|
||||
int i;
|
||||
@@ -310,12 +311,6 @@ int ProcessSrvRqst(SLPMessage message,
|
||||
int size = 0;
|
||||
SLPUrlEntry * urlentry;
|
||||
@@ -408,11 +408,6 @@ static int ProcessSrvRqst(SLPMessage * m
|
||||
size_t size = 0;
|
||||
SLPBuffer result = *sendbuf;
|
||||
|
||||
-#ifdef ENABLE_SLPv2_SECURITY
|
||||
@ -73,11 +77,10 @@
|
||||
- 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,
|
||||
/* If errorcode is set, we can not be sure that message is good
|
||||
Go directly to send response code
|
||||
*/
|
||||
@@ -514,32 +509,26 @@ RESPOND:
|
||||
{
|
||||
for (i = 0; i < db->urlcount; i++)
|
||||
{
|
||||
@ -93,10 +96,10 @@
|
||||
- /* 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 (G_SlpdProperty.securityEnabled
|
||||
- && message->body.srvrqst.spistrlen)
|
||||
+#ifdef ENABLE_SLPv1
|
||||
+ if (urlentry->opaque == 0)
|
||||
{
|
||||
- for (j = 0; j < urlentry->authcount; j++)
|
||||
@ -115,17 +118,17 @@
|
||||
+ /* 2 bytes for lifetime */
|
||||
+ /* 2 bytes for urllen */
|
||||
+ /* 1 byte for authcount */
|
||||
+ }
|
||||
}
|
||||
+ else
|
||||
#endif
|
||||
+ {
|
||||
+ size += urlentry->opaquelen;
|
||||
}
|
||||
-#endif
|
||||
+ }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -523,6 +509,10 @@ int ProcessSrvRqst(SLPMessage message,
|
||||
|
||||
@@ -590,6 +579,10 @@ RESPOND:
|
||||
PutUINT16(&result->curpos, db->urlcount);
|
||||
for (i = 0; i < db->urlcount; i++)
|
||||
{
|
||||
+ /* check size limitation */
|
||||
@ -135,17 +138,16 @@
|
||||
/* 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
|
||||
@@ -1337,7 +1330,7 @@ static int ProcessSAAdvert(SLPMessage *
|
||||
*/
|
||||
int SLPDProcessMessage(struct sockaddr_storage * peerinfo,
|
||||
struct sockaddr_storage * localaddr, SLPBuffer recvbuf,
|
||||
- SLPBuffer * sendbuf, SLPList * psendlist)
|
||||
+ SLPBuffer * sendbuf, SLPList * psendlist, int truncate)
|
||||
{
|
||||
SLPHeader header;
|
||||
SLPMessage * message = 0;
|
||||
@@ -1398,7 +1391,7 @@ int SLPDProcessMessage(struct sockaddr_s
|
||||
switch (message->header.functionid)
|
||||
{
|
||||
case SLP_FUNCT_SRVRQST:
|
||||
@ -154,35 +156,34 @@
|
||||
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_process.h.orig 2014-02-14 14:39:26.340721146 +0000
|
||||
+++ ./slpd/slpd_process.h 2014-02-14 14:39:38.538721124 +0000
|
||||
@@ -55,7 +55,7 @@
|
||||
int CheckAndResizeBuffer(SLPBuffer * sendbuf, SLPBuffer tmp, size_t grow_size);
|
||||
int SLPDProcessMessage(struct sockaddr_storage * peerinfo,
|
||||
struct sockaddr_storage * localaddr, SLPBuffer recvbuf,
|
||||
- SLPBuffer * sendbuf, SLPList * psendlist);
|
||||
+ SLPBuffer * sendbuf, SLPList * psendlist, int truncate);
|
||||
|
||||
|
||||
/*-------------------------------------*/
|
||||
--- ./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;
|
||||
#if defined(ENABLE_SLPv1)
|
||||
int SLPDv1ProcessMessage(struct sockaddr_storage * peeraddr,
|
||||
--- ./slpd/slpd_property.c.orig 2014-02-14 14:39:50.229721103 +0000
|
||||
+++ ./slpd/slpd_property.c 2014-02-14 14:40:54.266720990 +0000
|
||||
@@ -142,6 +142,7 @@ void SLPDPropertyReinit(void)
|
||||
G_SlpdProperty.securityEnabled = SLPPropertyAsBoolean("net.slp.securityEnabled");
|
||||
G_SlpdProperty.checkSourceAddr = SLPPropertyAsBoolean("net.slp.checkSourceAddr");
|
||||
G_SlpdProperty.DAHeartBeat = SLPPropertyAsInteger("net.slp.DAHeartBeat");
|
||||
+ G_SlpdProperty.oversizedUDP = SLPPropertyAsBoolean("net.slp.oversizedUDP");
|
||||
if (G_SlpdProperty.staleDACheckPeriod > 0)
|
||||
{
|
||||
/* Adjust the heartbeat interval if we need to send it faster for
|
||||
--- ./slpd/slpd_property.h.orig 2014-02-14 14:39:55.205721095 +0000
|
||||
+++ ./slpd/slpd_property.h 2014-02-14 14:41:11.378720960 +0000
|
||||
@@ -116,6 +116,7 @@ typedef struct _SLPDProperty
|
||||
int appendLog;
|
||||
int MTU;
|
||||
int useDHCP;
|
||||
+ int oversizedUDP;
|
||||
} SLPDProperty;
|
||||
|
||||
|
||||
extern SLPDProperty G_SlpdProperty;
|
||||
|
@ -1,237 +0,0 @@
|
||||
From: Jeff Mahoney <jeffm@suse.com>
|
||||
Subject: openslp: Use TCPDIAG for checking listeners
|
||||
References: bnc#601002
|
||||
|
||||
The use of /proc/net/tcp is deprecated and can cause performance issues on
|
||||
large systems. The issue is that there are a great many locks that must
|
||||
be claimed and released in order to produce the contents of the proc file.
|
||||
|
||||
The replacement mechanism is to use the INETDIAG/TCPDIAG interface to
|
||||
get the results. This has the advantage of using in-kernel filtering as
|
||||
well as a binary interface so that the parsing of the proc file is
|
||||
unnecessary.
|
||||
|
||||
Support is limited to TCP so the use of /proc/net/udp is still required.
|
||||
|
||||
If for whatever reason the netlink connection is lost and can't be
|
||||
re-established, we fall back to reading /proc/net/tcp until the daemon
|
||||
is restarted.
|
||||
|
||||
Signed-off-by: Jeff Mahoney <jeffm@suse.com>
|
||||
---
|
||||
slpd/slpd_database.c | 179 ++++++++++++++++++++++++++++++++++++++++++++++++++-
|
||||
1 file changed, 176 insertions(+), 3 deletions(-)
|
||||
|
||||
--- a/slpd/slpd_database.c
|
||||
+++ b/slpd/slpd_database.c
|
||||
@@ -76,6 +76,9 @@ FILE *regfileFP;
|
||||
/* standard header files */
|
||||
/*=========================================================================*/
|
||||
#include <dirent.h>
|
||||
+#include <linux/netlink.h>
|
||||
+#include <linux/inet_diag.h>
|
||||
+#include <sched.h>
|
||||
|
||||
/*=========================================================================*/
|
||||
SLPDDatabase G_SlpdDatabase;
|
||||
@@ -919,11 +922,176 @@ static void SLPDDatabaseWatcher_fd(int f
|
||||
}
|
||||
}
|
||||
|
||||
+enum {
|
||||
+ SS_UNKNOWN,
|
||||
+ SS_ESTABLISHED,
|
||||
+ SS_SYN_SENT,
|
||||
+ SS_SYN_RECV,
|
||||
+ SS_FIN_WAIT1,
|
||||
+ SS_FIN_WAIT2,
|
||||
+ SS_TIME_WAIT,
|
||||
+ SS_CLOSE,
|
||||
+ SS_CLOSE_WAIT,
|
||||
+ SS_LAST_ACK,
|
||||
+ SS_LISTEN,
|
||||
+ SS_CLOSING,
|
||||
+ SS_MAX
|
||||
+};
|
||||
+
|
||||
+#define SS_ALL ((1<<SS_MAX)-1)
|
||||
+
|
||||
+static int reconnect_nl(int *fd)
|
||||
+{
|
||||
+ int new_fd = socket(AF_NETLINK, SOCK_RAW, NETLINK_INET_DIAG);
|
||||
+
|
||||
+ close (*fd);
|
||||
+
|
||||
+ if (new_fd < 0)
|
||||
+ return errno;
|
||||
+
|
||||
+ *fd = new_fd;
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
+static void SLPDDatabaseWatcher_nl(int *fd, int flag, unsigned char *porthash)
|
||||
+{
|
||||
+ char buf[8192];
|
||||
+ int port, status = 0;
|
||||
+ SLPDatabaseHandle dh;
|
||||
+
|
||||
+ struct sockaddr_nl nladdr = {
|
||||
+ .nl_family = AF_NETLINK
|
||||
+ };
|
||||
+
|
||||
+ struct {
|
||||
+ struct nlmsghdr nlh;
|
||||
+ struct inet_diag_req r;
|
||||
+ } req = {
|
||||
+ .nlh = {
|
||||
+ .nlmsg_len = sizeof(req),
|
||||
+ .nlmsg_type = TCPDIAG_GETSOCK,
|
||||
+ .nlmsg_flags = NLM_F_ROOT|NLM_F_MATCH|NLM_F_REQUEST,
|
||||
+ .nlmsg_pid = 0,
|
||||
+ .nlmsg_seq = 123456,
|
||||
+ },
|
||||
+ .r = {
|
||||
+ .idiag_family = AF_INET,
|
||||
+ .idiag_states = 1 << SS_LISTEN,
|
||||
+ .idiag_ext = ((1 << (INET_DIAG_INFO - 1)) |
|
||||
+ (1 << (INET_DIAG_VEGASINFO - 1)) |
|
||||
+ (1 << (INET_DIAG_CONG - 1))),
|
||||
+ }
|
||||
+ };
|
||||
+
|
||||
+ struct iovec iov = {
|
||||
+ .iov_base = &req,
|
||||
+ .iov_len = sizeof(req),
|
||||
+ };
|
||||
+
|
||||
+ struct msghdr msg = {
|
||||
+ .msg_name = (void *)&nladdr,
|
||||
+ .msg_namelen = sizeof(nladdr),
|
||||
+ .msg_iov = &iov,
|
||||
+ .msg_iovlen = 1,
|
||||
+ };
|
||||
+ struct in_addr ipv4_loopback = { htonl(INADDR_LOOPBACK) };
|
||||
+ struct in6_addr ipv6_loopback = IN6ADDR_LOOPBACK_INIT;
|
||||
+ int retries;
|
||||
+
|
||||
+ /* If the socket shuts down for whatever reason, we need to
|
||||
+ * reopen it. Since we can't listen to a socket for which we have
|
||||
+ * made a request, we reissue the request and listen again. */
|
||||
+retry_sendmsg:
|
||||
+ retries = 2;
|
||||
+ while (retries-- > 0) {
|
||||
+ if (sendmsg(*fd, &msg, 0) >= 0)
|
||||
+ break;
|
||||
+
|
||||
+ if (reconnect_nl(fd)) {
|
||||
+ SLPDLog("Lost TCPDIAG netlink connection and attempts to "
|
||||
+ "re-establish have failed. Falling back to /proc/net/tcp "
|
||||
+ "for dead/alive updates.\n");
|
||||
+ *fd = -1;
|
||||
+ return;
|
||||
+ }
|
||||
+ sched_yield();
|
||||
+ }
|
||||
+
|
||||
+ iov.iov_base = buf;
|
||||
+ iov.iov_len = sizeof(buf);
|
||||
+
|
||||
+ dh = SLPDatabaseOpen(&G_SlpdDatabase.database);
|
||||
+ while (!status) {
|
||||
+ struct nlmsghdr *h;
|
||||
+
|
||||
+ status = recvmsg(*fd, &msg, 0);
|
||||
+ if (status < 0) {
|
||||
+ if (errno == EINTR)
|
||||
+ continue;
|
||||
+ goto retry_sendmsg;
|
||||
+ }
|
||||
+
|
||||
+ /* Socket has shut down */
|
||||
+ if (status == 0)
|
||||
+ goto retry_sendmsg;
|
||||
+
|
||||
+ for (h = (struct nlmsghdr *) buf; NLMSG_OK(h, status);
|
||||
+ h = NLMSG_NEXT(h, status)) {
|
||||
+ SLPDatabaseEntry *entry;
|
||||
+ struct inet_diag_msg *r = NLMSG_DATA(h);
|
||||
+
|
||||
+ if (h->nlmsg_seq != 123456)
|
||||
+ continue;
|
||||
+
|
||||
+ if (h->nlmsg_type == NLMSG_DONE)
|
||||
+ goto close;
|
||||
+
|
||||
+ if (h->nlmsg_type == NLMSG_ERROR) {
|
||||
+ struct nlmsgerr *err = NLMSG_DATA(h);
|
||||
+ if (h->nlmsg_len >= NLMSG_LENGTH(sizeof(*err)))
|
||||
+ status = EINVAL;
|
||||
+ else
|
||||
+ status = -err->error;
|
||||
+ break;
|
||||
+ }
|
||||
+
|
||||
+ if (r->idiag_family != AF_INET && r->idiag_family != AF_INET6)
|
||||
+ continue;
|
||||
+
|
||||
+ if (r->idiag_family == AF_INET &&
|
||||
+ ipv4_loopback.s_addr == r->id.idiag_src[0])
|
||||
+ continue;
|
||||
+
|
||||
+ if (r->idiag_family == AF_INET6 &&
|
||||
+ !memcmp(ipv6_loopback.s6_addr32, r->id.idiag_src,
|
||||
+ sizeof(ipv6_loopback)))
|
||||
+ continue;
|
||||
+
|
||||
+ port = ntohs(r->id.idiag_sport);
|
||||
+ if (!(porthash[(port / 8) & 255] & (1 << (port & 7))))
|
||||
+ continue;
|
||||
+
|
||||
+ SLPDatabaseRewind(dh);
|
||||
+
|
||||
+ while ((entry = SLPDatabaseEnum(dh)) != 0) {
|
||||
+ SLPSrvReg *srvreg = &(entry->msg->body.srvreg);
|
||||
+ if (!(srvreg->watchflags & flag))
|
||||
+ continue;
|
||||
+ if (port == srvreg->watchport)
|
||||
+ srvreg->watchflags &= ~SLP_REG_WATCH_CHECKING;
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+close:
|
||||
+ SLPDatabaseClose(dh);
|
||||
+}
|
||||
+
|
||||
/*=========================================================================*/
|
||||
void SLPDDatabaseWatcher(void)
|
||||
{
|
||||
static int initialized = 0;
|
||||
- static int proctcp, procudp, proctcp6, procudp6;
|
||||
+ static int proctcp, procudp, proctcp6, procudp6, inet_diag = -1;
|
||||
unsigned char porthash[256];
|
||||
int flags, port;
|
||||
SLPDatabaseHandle dh;
|
||||
@@ -931,6 +1099,7 @@ void SLPDDatabaseWatcher(void)
|
||||
SLPSrvReg* srvreg;
|
||||
|
||||
if (!initialized) {
|
||||
+ inet_diag = socket(AF_NETLINK, SOCK_RAW, NETLINK_INET_DIAG);
|
||||
proctcp = open("/proc/net/tcp_listen", O_RDONLY);
|
||||
if (proctcp == -1)
|
||||
proctcp = open("/proc/net/tcp", O_RDONLY);
|
||||
@@ -955,8 +1124,12 @@ void SLPDDatabaseWatcher(void)
|
||||
}
|
||||
SLPDatabaseClose(dh);
|
||||
if ((flags & SLP_REG_WATCH_TCP) != 0) {
|
||||
- SLPDDatabaseWatcher_fd(proctcp, SLP_REG_WATCH_TCP, porthash);
|
||||
- SLPDDatabaseWatcher_fd(proctcp6, SLP_REG_WATCH_TCP, porthash);
|
||||
+ if (inet_diag >= 0)
|
||||
+ SLPDDatabaseWatcher_nl(&inet_diag, SLP_REG_WATCH_TCP, porthash);
|
||||
+ if (inet_diag < 0) { /* Fallback if _nl fails */
|
||||
+ SLPDDatabaseWatcher_fd(proctcp, SLP_REG_WATCH_TCP, porthash);
|
||||
+ SLPDDatabaseWatcher_fd(proctcp6, SLP_REG_WATCH_TCP, porthash);
|
||||
+ }
|
||||
}
|
||||
if ((flags & SLP_REG_WATCH_UDP) != 0) {
|
||||
SLPDDatabaseWatcher_fd(procudp, SLP_REG_WATCH_UDP, porthash);
|
@ -1,34 +0,0 @@
|
||||
--- ./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)
|
||||
{
|
||||
/*------------------------------------------------------------*/
|
@ -1,13 +1,14 @@
|
||||
--- libslp/Makefile.am.orig
|
||||
+++ libslp/Makefile.am
|
||||
@@ -26,4 +26,4 @@ libslp_la_SOURCES = libslp_dereg.c \
|
||||
libslp_mdns.c \
|
||||
libslp.h
|
||||
--- ./libslp/Makefile.am.orig 2014-02-17 18:11:45.472239824 +0000
|
||||
+++ ./libslp/Makefile.am 2014-02-17 18:12:27.793239750 +0000
|
||||
@@ -57,5 +57,5 @@ noinst_HEADERS = \
|
||||
|
||||
libslp_la_LIBADD = ../common/libcommonlibslp.la
|
||||
|
||||
-libslp_la_LDFLAGS = -version-info 1:0:0
|
||||
+libslp_la_LDFLAGS = -Wl,--version-script=$(srcdir)/libslp.map -version-info 1:0:0
|
||||
--- /dev/null
|
||||
+++ libslp/libslp.map
|
||||
|
||||
--- ./libslp/libslp.map.orig 2014-02-17 18:13:11.931239671 +0000
|
||||
+++ ./libslp/libslp.map 2014-02-17 18:11:45.472239824 +0000
|
||||
@@ -0,0 +1,25 @@
|
||||
+{
|
||||
+global:
|
@ -1,11 +0,0 @@
|
||||
--- 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,
|
@ -1,67 +0,0 @@
|
||||
--- ./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))
|
Loading…
x
Reference in New Issue
Block a user