summaryrefslogtreecommitdiffstats
path: root/runtime
diff options
context:
space:
mode:
authorRainer Gerhards <rgerhards@adiscon.com>2011-06-07 10:47:06 +0200
committerRainer Gerhards <rgerhards@adiscon.com>2011-06-07 10:47:06 +0200
commit363c16b9de007b2abb72edc08fc600a59e0fb1a1 (patch)
treea25e3a4cbf555e1d64d1fa0a97c841b065233c04 /runtime
parentddad5b3299191142f500b25e01b827e40e873cd7 (diff)
downloadrsyslog-363c16b9de007b2abb72edc08fc600a59e0fb1a1.tar.gz
rsyslog-363c16b9de007b2abb72edc08fc600a59e0fb1a1.tar.xz
rsyslog-363c16b9de007b2abb72edc08fc600a59e0fb1a1.zip
dnscache: bugfix, potentially grabagge data accessed
This was a bug of the new implementation, never released code.
Diffstat (limited to 'runtime')
-rw-r--r--runtime/dnscache.c10
-rw-r--r--runtime/nsd_ptcp.c4
2 files changed, 8 insertions, 6 deletions
diff --git a/runtime/dnscache.c b/runtime/dnscache.c
index 5bee47c4..6cea43dc 100644
--- a/runtime/dnscache.c
+++ b/runtime/dnscache.c
@@ -115,10 +115,11 @@ static inline dnscache_entry_t*
findEntry(struct sockaddr_storage *addr)
{
dnscache_entry_t *etry;
- for( etry = dnsCache.root
- ; etry != NULL && !memcmp(addr, &etry->addr, sizeof(struct sockaddr_storage))
- ; etry = etry->next)
- /* just search, no other processing necessary */;
+ for(etry = dnsCache.root ; etry != NULL ; etry = etry->next) {
+ if(SALEN((struct sockaddr*)addr) == SALEN((struct sockaddr*) &etry->addr)
+ && !memcmp(addr, &etry->addr, SALEN((struct sockaddr*) addr)))
+ break; /* in this case, we found our entry */
+ }
if(etry != NULL)
++etry->nUsed; /* this is *not* atomic, but we can live with an occasional loss! */
return etry;
@@ -287,6 +288,7 @@ addEntry(struct sockaddr_storage *addr, dnscache_entry_t **pEtry)
CHKmalloc(etry = MALLOC(sizeof(dnscache_entry_t)));
CHKmalloc(etry->pszHostFQDN = ustrdup(pszHostFQDN));
CHKmalloc(etry->ip = ustrdup(ip));
+ memcpy(&etry->addr, addr, SALEN((struct sockaddr*) addr));
etry->nUsed = 0;
*pEtry = etry;
diff --git a/runtime/nsd_ptcp.c b/runtime/nsd_ptcp.c
index 06f62b7e..fd883d21 100644
--- a/runtime/nsd_ptcp.c
+++ b/runtime/nsd_ptcp.c
@@ -249,7 +249,7 @@ Abort(nsd_t *pNsd)
* rgerhards, 2008-03-31
*/
static rsRetVal
-FillRemHost(nsd_ptcp_t *pThis, struct sockaddr *pAddr)
+FillRemHost(nsd_ptcp_t *pThis, struct sockaddr_storage *pAddr)
{
uchar szIP[NI_MAXHOST] = "";
uchar szHname[NI_MAXHOST] = "";
@@ -314,7 +314,7 @@ AcceptConnReq(nsd_t *pNsd, nsd_t **ppNew)
* of this function. -- rgerhards, 2008-12-01
*/
memcpy(&pNew->remAddr, &addr, sizeof(struct sockaddr_storage));
- CHKiRet(FillRemHost(pNew, (struct sockaddr*) &addr));
+ CHKiRet(FillRemHost(pNew, &addr));
/* set the new socket to non-blocking IO -TODO:do we really need to do this here? Do we always want it? */
if((sockflags = fcntl(iNewSock, F_GETFL)) != -1) {