From 0a1883047d6874857fe2848e3212fed881da695d Mon Sep 17 00:00:00 2001 From: "Maciej S. Szmigiero" Date: Sun, 24 Mar 2019 00:50:19 +0100 Subject: [PATCH] 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. --- src/anchor.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/anchor.c b/src/anchor.c index 09f71232..16fd8042 100644 --- a/src/anchor.c +++ b/src/anchor.c @@ -1086,11 +1086,11 @@ static void tas_connect(getdns_context *context, tas_connection *a) } if (a->state == TAS_RETRY_GET_PS7) { 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; } else { 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; } if (!(write_buf = GETDNS_XMALLOC(context->mf, char, buf_sz))) {