Don't transmit an extra NULL byte in the anchor fetch HTTP request

When calculating HTTP request buffer size tas_connect() unnecessarily adds
an extra octet for the terminating NULL byte.
The terminating NULL was already accounted for by sizeof(fmt), however,
since sizeof("123") = 4.

The extra NULL byte at the end of the anchor fetch HTTP request resulted
in an extra "501 Not implemented" HTTP response from the trust anchor
server.
This commit is contained in:
Maciej S. Szmigiero 2019-03-24 00:50:19 +01:00
parent 99e32f1e46
commit 0a1883047d
No known key found for this signature in database
GPG Key ID: 52B1D6E951D0CE07
1 changed files with 2 additions and 2 deletions

View File

@ -1086,11 +1086,11 @@ static void tas_connect(getdns_context *context, tas_connection *a)
} }
if (a->state == TAS_RETRY_GET_PS7) { if (a->state == TAS_RETRY_GET_PS7) {
buf_sz = sizeof(tas_write_p7s_buf) buf_sz = sizeof(tas_write_p7s_buf)
+ 1 * (hostname_len - 2) + 1 * (path_len - 2) + 1; + 1 * (hostname_len - 2) + 1 * (path_len - 2);
fmt = tas_write_p7s_buf; fmt = tas_write_p7s_buf;
} else { } else {
buf_sz = sizeof(tas_write_xml_p7s_buf) buf_sz = sizeof(tas_write_xml_p7s_buf)
+ 2 * (hostname_len - 2) + 2 * (path_len - 2) + 1; + 2 * (hostname_len - 2) + 2 * (path_len - 2);
fmt = tas_write_xml_p7s_buf; fmt = tas_write_xml_p7s_buf;
} }
if (!(write_buf = GETDNS_XMALLOC(context->mf, char, buf_sz))) { if (!(write_buf = GETDNS_XMALLOC(context->mf, char, buf_sz))) {