Skip to content

Commit

Permalink
Merge pull request #570 from pi-hole/hotfix/v4.3.1
Browse files Browse the repository at this point in the history
Hotfix v4.3.1
  • Loading branch information
DL6ER authored May 25, 2019
2 parents 9e8273b + 19921e8 commit b60d63f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
3 changes: 2 additions & 1 deletion networktable.c
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,6 @@ void parse_arp_cache(void)
// unknown (only DNS requesting clients do this)
lock_shm();
int clientID = findClientID(ip, false);
unlock_shm();

// This client is known (by its IP address) to pihole-FTL if
// findClientID() returned a non-negative index
Expand Down Expand Up @@ -177,6 +176,8 @@ void parse_arp_cache(void)
// else:
// Device in database but not known to Pi-hole: No action required

unlock_shm();

// Count number of processed ARP cache entries
entries++;
}
Expand Down
12 changes: 9 additions & 3 deletions resolve.c
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,11 @@ static char *resolveHostname(const char *addr)
// Resolve upstream destination host names
static size_t resolveAndAddHostname(size_t ippos, size_t oldnamepos)
{
// Get IP and host name strings
// Get IP and host name strings. They are cloned in case shared memory is
// resized before the next lock
lock_shm();
const char* ipaddr = getstr(ippos);
const char* oldname = getstr(oldnamepos);
char* ipaddr = strdup(getstr(ippos));
char* oldname = strdup(getstr(oldnamepos));
unlock_shm();

// Important: Don't hold a lock while resolving as the main thread
Expand All @@ -86,6 +87,8 @@ static size_t resolveAndAddHostname(size_t ippos, size_t oldnamepos)
// newname has already been checked against NULL
// so we can safely free it
free(newname);
free(ipaddr);
free(oldname);
unlock_shm();
return newnamepos;
}
Expand All @@ -95,6 +98,9 @@ static size_t resolveAndAddHostname(size_t ippos, size_t oldnamepos)
logg("Not adding \"%s\" to buffer (unchanged)", oldname);
}

free(ipaddr);
free(oldname);

// Not changed, return old namepos
return oldnamepos;
}
Expand Down

0 comments on commit b60d63f

Please sign in to comment.