From 3992a37c06d382a2df50dcfc98c8e55921d1b80f Mon Sep 17 00:00:00 2001 From: Mark Andrews Date: Fri, 14 Sep 2018 15:49:51 +1000 Subject: [PATCH] only emit a single space between mac length and the orginal id if the mac length is zero (cherry picked from commit ac1c3aaa27e9027ab40a2a2d20ce8b7d8b0e1623) --- lib/dns/rdata/any_255/tsig_250.c | 34 ++++++++++++++++++-------------- 1 file changed, 19 insertions(+), 15 deletions(-) diff --git a/lib/dns/rdata/any_255/tsig_250.c b/lib/dns/rdata/any_255/tsig_250.c index 538c9ec1f62..5cb24b2b5d5 100644 --- a/lib/dns/rdata/any_255/tsig_250.c +++ b/lib/dns/rdata/any_255/tsig_250.c @@ -187,22 +187,26 @@ totext_any_tsig(ARGS_TOTEXT) { /* * Signature. */ - REQUIRE(n <= sr.length); - sigr = sr; - sigr.length = n; - if ((tctx->flags & DNS_STYLEFLAG_MULTILINE) != 0) - RETERR(str_totext(" (", target)); - RETERR(str_totext(tctx->linebreak, target)); - if (tctx->width == 0) /* No splitting */ - RETERR(isc_base64_totext(&sigr, 60, "", target)); - else - RETERR(isc_base64_totext(&sigr, tctx->width - 2, - tctx->linebreak, target)); - if ((tctx->flags & DNS_STYLEFLAG_MULTILINE) != 0) - RETERR(str_totext(" ) ", target)); - else + if (n != 0U) { + REQUIRE(n <= sr.length); + sigr = sr; + sigr.length = n; + if ((tctx->flags & DNS_STYLEFLAG_MULTILINE) != 0) + RETERR(str_totext(" (", target)); + RETERR(str_totext(tctx->linebreak, target)); + if (tctx->width == 0) /* No splitting */ + RETERR(isc_base64_totext(&sigr, 60, "", target)); + else + RETERR(isc_base64_totext(&sigr, tctx->width - 2, + tctx->linebreak, target)); + if ((tctx->flags & DNS_STYLEFLAG_MULTILINE) != 0) + RETERR(str_totext(" ) ", target)); + else + RETERR(str_totext(" ", target)); + isc_region_consume(&sr, n); + } else { RETERR(str_totext(" ", target)); - isc_region_consume(&sr, n); + } /* * Original ID. -- GitLab