Skip to content

Commit

Permalink
Merge pull request #110 from jelu/fix-fqdn-parse
Browse files Browse the repository at this point in the history
FQDN parsing
  • Loading branch information
jelu committed Jun 2, 2022
2 parents f0ce9ae + 4ec95e7 commit d031af7
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/dns.h
Expand Up @@ -112,7 +112,7 @@ class DNSMessage {

class Name {
public:
char fqdn[512];
char fqdn[2048]; // escaping needs *4 the space
int labels;

Name()
Expand Down Expand Up @@ -243,7 +243,6 @@ class DNSMessage {
int savedoffs = 0;
int n = get_ubyte(offs++);
char* out = &name.fqdn[0];
int size = sizeof(name.fqdn);
if (n == 0)
out[p++] = '.';

Expand All @@ -262,7 +261,8 @@ class DNSMessage {
}

// if the string is too long restart and mess it up
if (n + 20 + p > size / 2)
// check if we can fit a fully escaped label + . and reserve for zeroing it later
if (p + (n * 4) + 1 > sizeof(name.fqdn) - 1)
p = 0;

while (n-- > 0) {
Expand Down

0 comments on commit d031af7

Please sign in to comment.