From: Mark Andrews Date: Fri, 21 Feb 2020 05:40:50 +0000 (-0800) Subject: Fix code to generate the test signatues. X-Git-Tag: v9.14.12~22^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5bf41b8133e73065c3b90eb6e2b98322f46439d8;p=thirdparty%2Fbind9.git Fix code to generate the test signatues. * ctx needs to be destroyed before it is regenerated. * emit the name of the signature to be replaced. * cleanup memory before asserting so post longjump doesn't detect a memory leak. * comment code. (cherry picked from commit 3a8c8a2a3199844bb16232e2f362f67d14181939) --- diff --git a/lib/dns/tests/dst_test.c b/lib/dns/tests/dst_test.c index 402f8238776..4ac02ad7d97 100644 --- a/lib/dns/tests/dst_test.c +++ b/lib/dns/tests/dst_test.c @@ -209,10 +209,17 @@ check_sig(const char *datapath, const char *sigpath, const char *keyname, assert_int_equal(result, ISC_R_SUCCESS); result = dst_context_verify(ctx, &sigreg); + /* + * Compute the expected signature and emit it + * so the precomputed signature can be updated. + * This should only be done if the covered data + * is updated. + */ if (expect && result != ISC_R_SUCCESS) { isc_result_t result2; + dst_context_destroy(&ctx); result2 = dst_context_create(key, mctx, DNS_LOGCATEGORY_GENERAL, - false, 0, &ctx); + false, 0, &ctx); assert_int_equal(result2, ISC_R_SUCCESS); result2 = dst_context_adddata(ctx, &datareg); @@ -234,18 +241,16 @@ check_sig(const char *datapath, const char *sigpath, const char *keyname, isc_hex_totext(&r, 0, "", &hb); - fprintf(stderr, "%s\n", hexbuf); - - dst_context_destroy(&ctx); + fprintf(stderr, "# %s:\n# %s\n", sigpath, hexbuf); } - assert_true((expect && (result == ISC_R_SUCCESS)) || - (!expect && (result != ISC_R_SUCCESS))); - isc_mem_put(mctx, data, size + 1); dst_context_destroy(&ctx); dst_key_free(&key); + assert_true((expect && (result == ISC_R_SUCCESS)) || + (!expect && (result != ISC_R_SUCCESS))); + return; }