diff options
author | tmarkwalder <tmark@isc.org> | 2017-05-03 08:42:22 -0400 |
---|---|---|
committer | tmarkwalder <tmark@isc.org> | 2017-05-03 08:42:22 -0400 |
commit | 2f5fefd3a806d9f4387200b0e0bf6dd9a6b9f85b (patch) | |
tree | 2feb73cbe42b64a56fc0794fa3c1e90b8aab00cf /common | |
parent | 121a56812d715a0fa7f4d78650171fb067715a7b (diff) | |
download | isc-dhcp-2f5fefd3a806d9f4387200b0e0bf6dd9a6b9f85b.tar.gz |
[master] v6 FQDN option unpacking now handles values with spaces and non-printables
Merged in rt43592.
Diffstat (limited to 'common')
-rw-r--r-- | common/options.c | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/common/options.c b/common/options.c index 223726ca..b0dcab42 100644 --- a/common/options.c +++ b/common/options.c @@ -3594,12 +3594,17 @@ fqdn6_universe_decode(struct option_state *options, return 0; /* Save the contents of the option in a buffer. There are 3 - * one-byte values we record from the packet, so we go ahead - * and allocate a bigger buffer to accommodate them. But the - * 'length' we got (because it is a DNS encoded string) is - * one longer than we need...so we only add two extra octets. - */ - if (!buffer_allocate(&bp, length + 2, MDL)) { + * one-byte values we record from the packet. The input is + * DNS encoded and to be safe we'll assume that each character + * is non-printable and will be converted to an escaped number: + * "\\nnn". Yes, we'll have dead space pretty much all the time + * but the alternative is to basically dry run the conversion + * first to calculate the precise size or reallocate to a smaller + * buffer later, either of which is a bigger performance hit than + * just doing a generous allocation. */ + unsigned bp_size = 3 + (length * 4); + + if (!buffer_allocate(&bp, bp_size, MDL)) { log_error("No memory for dhcp6.fqdn option buffer."); return 0; } @@ -3611,7 +3616,6 @@ fqdn6_universe_decode(struct option_state *options, goto error; /* XXX: We need to process 'The "N" bit'. */ - if (buffer[0] & 1) /* server-update. */ bp->data[2] = 1; else @@ -3631,7 +3635,7 @@ fqdn6_universe_decode(struct option_state *options, goto error; /* Convert the domain name to textual representation for config. */ - len = MRns_name_ntop(buffer + 1, (char *)bp->data + 3, length - 1); + len = MRns_name_ntop(buffer + 1, (char *)bp->data + 3, bp_size - 3); if (len == -1) { log_error("Unable to convert dhcp6.fqdn domain name to " "printable form."); |