Skip to content

Commit

Permalink
[dns] Allow trailing dots in DNS names
Browse files Browse the repository at this point in the history
Reported-by: Christian Hesse <list@eworm.de>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
  • Loading branch information
mcb30 committed Jan 10, 2012
1 parent 55f6c88 commit 187cd80
Showing 1 changed file with 15 additions and 9 deletions.
24 changes: 15 additions & 9 deletions src/net/udp/dns.c
Expand Up @@ -222,18 +222,24 @@ static char * dns_qualify_name ( const char *string ) {
* DNS names consist of "<length>element" pairs.
*/
static char * dns_make_name ( const char *string, char *buf ) {
char *length_byte = buf++;
char *length_byte;
char c;

while ( ( c = *(string++) ) ) {
if ( c == '.' ) {
*length_byte = buf - length_byte - 1;
length_byte = buf;
length_byte = buf++;
*length_byte = 0;
do {
c = *(string++);
if ( ( c == '.' ) || ( c == '\0' ) ) {
if ( *length_byte ) {
length_byte = buf++;
*length_byte = 0;
}
} else {
*(buf++) = c;
(*length_byte)++;
}
*(buf++) = c;
}
*length_byte = buf - length_byte - 1;
*(buf++) = '\0';
} while ( c );

return buf;
}

Expand Down

0 comments on commit 187cd80

Please sign in to comment.