diff --git a/discover.c b/discover.c index 91735bd..5575592 100644 --- a/discover.c +++ b/discover.c @@ -233,7 +233,7 @@ void cSatipDiscover::AddServer(const char *addrP, const char *modelP, const char { debug1("%s (%s, %s, %s)", __PRETTY_FUNCTION__, addrP, modelP, descP); cMutexLock MutexLock(&mutexM); - if (SatipConfig.GetUseSingleModelServers()) { + if (SatipConfig.GetUseSingleModelServers() && modelP && !isempty(modelP)) { int n = 0; char *s, *p = strdup(modelP); char *r = strtok_r(p, ",", &s); diff --git a/param.c b/param.c index d999a8f..b4a5faf 100644 --- a/param.c +++ b/param.c @@ -192,7 +192,7 @@ cString GetTransponderUrlParameters(const cChannel *channelP) ST(" T*") q += PrintUrlString(q, STBUFLEFT, dtp.System(), SatipSystemValuesTerrestrial); ST(" T*") q += PrintUrlString(q, STBUFLEFT, dtp.Transmission(), SatipTransmissionValues); if ((channelP->Rid() % 100) > 0) - q += snprintf(q, STBUFLEFT, "&fe=%d", channelP->Rid() % 100); + snprintf(q, STBUFLEFT, "&fe=%d", channelP->Rid() % 100); #undef ST return buffer; } diff --git a/socket.c b/socket.c index 358d506..ead7ec1 100644 --- a/socket.c +++ b/socket.c @@ -136,12 +136,17 @@ int cSatipSocket::Read(unsigned char *bufferAddrP, unsigned int bufferLenP) int cSatipSocket::ReadMulti(unsigned char *bufferAddrP, unsigned int *elementRecvSizeP, unsigned int elementCountP, unsigned int elementBufferSizeP) { debug16("%s (, , %d, %d)", __PRETTY_FUNCTION__, elementCountP, elementBufferSizeP); -#if defined(__GLIBC_PREREQ) && __GLIBC_PREREQ(2,12) + int count = -1; // Error out if socket not initialized if (socketDescM <= 0) { error("%s Invalid socket", __PRETTY_FUNCTION__); return -1; } + if (!bufferAddrP || !elementRecvSizeP || !elementCountP || !elementBufferSizeP) { + error("%s Invalid parameter(s)", __PRETTY_FUNCTION__); + return -1; + } +#if defined(__GLIBC_PREREQ) && __GLIBC_PREREQ(2,12) // Initialize iov and msgh structures struct mmsghdr mmsgh[elementCountP]; struct iovec iov[elementCountP]; @@ -154,14 +159,12 @@ int cSatipSocket::ReadMulti(unsigned char *bufferAddrP, unsigned int *elementRec } // Read data from socket as a set - int count = -1; - if (socketDescM && bufferAddrP && elementRecvSizeP && (elementCountP > 0) && (elementBufferSizeP > 0)) - count = (int)recvmmsg(socketDescM, mmsgh, elementCountP, MSG_DONTWAIT, NULL); + count = (int)recvmmsg(socketDescM, mmsgh, elementCountP, MSG_DONTWAIT, NULL); ERROR_IF_RET(count < 0 && errno != EAGAIN && errno != EWOULDBLOCK, "recvmmsg()", return -1); for (int i = 0; i < count; ++i) elementRecvSizeP[i] = mmsgh[i].msg_len; #else - int count = 0; + count = 0; while (count < (int)elementCountP) { int len = Read(bufferAddrP + count * elementBufferSizeP, elementBufferSizeP); if (len < 0)