mirror of
https://github.com/pi-hole/FTL.git
synced 2024-10-26 16:52:18 +02:00
Fix very long DNS names (>64 bytes) potentially crashing the internal name resolving mechanism, the new limit is 256 bytes with proper boundary checking
Signed-off-by: DL6ER <dl6er@dl6er.de>
This commit is contained in:
+3
-2
@@ -449,7 +449,8 @@ static char *__attribute__((malloc)) ngethostbyname(const int sock, struct socka
|
||||
// 3www6google3com -> www.google.com
|
||||
static u_char * __attribute__((malloc)) __attribute__((nonnull(1,2,3))) name_fromDNS(unsigned char *reader, unsigned char *buffer, uint16_t *count)
|
||||
{
|
||||
unsigned char *name = calloc(MAXHOSTNAMELEN, sizeof(char));
|
||||
const size_t MAXNAMELEN = 256;
|
||||
unsigned char *name = calloc(MAXNAMELEN, sizeof(char));
|
||||
unsigned int p = 0, jumped = 0;
|
||||
|
||||
// Initialize count
|
||||
@@ -462,7 +463,7 @@ static u_char * __attribute__((malloc)) __attribute__((nonnull(1,2,3))) name_fro
|
||||
// Instead, each label is preceded by a byte containing its length, and
|
||||
// the name is terminated by a zero-length label representing the root
|
||||
// zone.
|
||||
while(*reader != 0)
|
||||
while(*reader != 0 && p < MAXNAMELEN - 2)
|
||||
{
|
||||
if(*reader >= 0xC0)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user