[Pdns-dev] dnsparser.cc:simpleCompress()

Peter van Dijk peter.van.dijk at netherlabs.nl
Tue Jun 12 23:40:45 CEST 2012


Hello Johan,

On Jun 12, 2012, at 22:51 , Johan Ekenberg wrote:

> If I'm not mistaken, the basic usage case of simpleCompress() should just 
> return a record with dots removed, so that "foo.bar.com" becomes "foobarcom". 
> (?)

No - the basic usage case (when actual compression is not possible or feasible) is to return a record with the dots turned into label length indicators.

> Please look at these examples, is this the intended behaviour?
> ============================================
> $ ./test_simple_compress foo.1234567.com
> foo1234567com
> # OK

$ ./test_simple_compress foo.1234567.com | hexdump -C
00000000  03 66 6f 6f 07 31 32 33  34 35 36 37 03 63 6f 6d  |.foo.1234567.com|
00000010  00 0a                                             |..|

i.e.: <03>foo<07>1234567<03>com

> $ ./test_simple_compress foo.12345678.com
> fo12345678com
> # ERROR: foo became of

$ ./test_simple_compress foo.12345678.com | hexdump -C
00000000  03 66 6f 6f 08 31 32 33  34 35 36 37 38 03 63 6f  |.foo.12345678.co|
00000010  6d 00 0a                                          |m..|

i.e. <03>foo<08>12345678<03>com

note that ascii 8 is interpreted as backspace by many terminals - which is why you seem to be losing an o.

> $ ./test_simple_compress foo.123456789.com
> foo     123456789com
> # ERROR: whitespace

ascii 9 is a tab.

> $ ./test_simple_compress foo.1234567890.com
> foo
> 1234567890com
> # ERROR: newline

ascii 10 is a newline.

<some examples snipped>

> $ ./test_simple_compress foo.1234567890123.com
> 1234567890123com
> # ERROR: foo is gone

ascii 13 is carriage return - it puts the cursor at the start of the line again.

The behaviour of simpleCompress appears correct, at least under these tests. Your issues are due to your terminal assigning meaning to some of these characters.

I do wonder - what were you testing, or what were you trying to find out? We're here to help!

Kind regards,
-- 
Peter van Dijk
Netherlabs Computer Consulting BV - http://www.netherlabs.nl/



More information about the Pdns-dev mailing list