Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

misc.cc: Resize hostname to final size in getCarbonHostname() #9343

Merged
merged 2 commits into from Jul 28, 2020

Conversation

cmouse
Copy link
Contributor

@cmouse cmouse commented Jul 19, 2020

Short description

In 5c21b47 we change how hostname is allocated. We allocate getMaxHostNameSize for string, then give the raw buffer for gethostname function, but forget to resize the string into actual result length, causing the carbon output to include trailing NUL bytes after hostname.

Checklist

I have:

  • read the CONTRIBUTING.md document
  • compiled this code
  • tested this code
  • included documentation (including possible behaviour changes)
  • documented the code
  • added or modified regression test(s)
  • added or modified unit test(s)

@cmouse
Copy link
Contributor Author

cmouse commented Jul 19, 2020

Pre-patch wireshark result:

0000  70 64 6e 73 2e 6d 6f 72 64 6f 72 00 00 00 00 00   pdns.mordor.....
0010  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00   ................
0020  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00   ................
0030  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00   ................
0040  00 00 00 00 00 00 2e 72 65 63 75 72 73 6f 72 2e   .......recursor.
0050  61 6c 6c 2d 6f 75 74 71 75 65 72 69 65 73 20 31   all-outqueries 1
0060  20 31 35 39 35 31 37 31 36 34 35 0d 0a 70 64 6e    1595171645..pdn
0070  73 2e 6d 6f 72 64 6f 72 00 00 00 00 00 00 00 00   s.mordor........
0080  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00   ................
0090  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00   ................
00a0  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00   ................
00b0  00 00 00 2e 72 65 63 75 72 73 6f 72 2e 61 6e 73   ....recursor.ans
00c0  77 65 72 73 2d 73 6c 6f 77 20 30 20 31 35 39 35   wers-slow 0 1595
00d0  31 37 31 36 34 35 0d 0a 70 64 6e 73 2e 6d 6f 72   171645..pdns.mor
00e0  64 6f 72 00 00 00 00 00 00 00 00 00 00 00 00 00   dor.............
00f0  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00   ................
0100  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00   ................
0110  00 00 00 00 00 00 00 00 00 00 00 00 00 00 2e 72   ...............r
0120  65 63 75 72 73 6f 72 2e 61 6e 73 77 65 72 73 30   ecursor.answers0
0130  2d 31 20 30 20 31 35 39 35 31 37 31 36 34 35 0d   -1 0 1595171645.
0140  0a 70 64 6e 73 2e 6d 6f 72 64 6f 72 00 00 00 00   .pdns.mordor....
0150  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00   ................
0160  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00   ................
0170  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00   ................
0180  00 00 00 00 00 00 00 2e 72 65 63 75 72 73 6f 72   ........recursor
0190  2e 61 6e 73 77 65 72 73 31 2d 31 30 20 30 20 31   .answers1-10 0 1
01a0  35 39 35 31 37 31 36 34 35 0d 0a 70 64 6e 73 2e   595171645..

Post-patch wireshark result:

0000  70 64 6e 73 2e 6d 6f 72 64 6f 72 2e 72 65 63 75   pdns.mordor.recu
0010  72 73 6f 72 2e 61 6c 6c 2d 6f 75 74 71 75 65 72   rsor.all-outquer
0020  69 65 73 20 31 20 31 35 39 35 31 37 31 35 38 39   ies 1 1595171589
0030  0d 0a 70 64 6e 73 2e 6d 6f 72 64 6f 72 2e 72 65   ..pdns.mordor.re
0040  63 75 72 73 6f 72 2e 61 6e 73 77 65 72 73 2d 73   cursor.answers-s
0050  6c 6f 77 20 30 20 31 35 39 35 31 37 31 35 38 39   low 0 1595171589
0060  0d 0a 70 64 6e 73 2e 6d 6f 72 64 6f 72 2e 72 65   ..pdns.mordor.re
0070  63 75 72 73 6f 72 2e 61 6e 73 77 65 72 73 30 2d   cursor.answers0-
0080  31 20 30 20 31 35 39 35 31 37 31 35 38 39 0d 0a   1 0 1595171589..
0090  70 64 6e 73 2e 6d 6f 72 64 6f 72 2e 72 65 63 75   pdns.mordor.recu
00a0  72 73 6f 72 2e 61 6e 73 77 65 72 73 31 2d 31 30   rsor.answers1-10
00b0  20 30 20 31 35 39 35 31 37 31 35 38 39 0d 0a 70    0 1595171589..

@cmouse
Copy link
Contributor Author

cmouse commented Jul 19, 2020

Workaround: Set

carbon-hostname=whatever

cmouse added 2 commits Jul 21, 2020
In 5c21b47 we change how
hostname is allocated. We allocate getMaxHostNameSize for string,
then give the raw buffer for gethostname function, but forget to
resize the string into actual result length, causing the carbon
output to include trailing NUL bytes after hostname.
@rgacogne rgacogne merged commit c309dea into PowerDNS:master Jul 28, 2020
29 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants