diff --git a/CHANGES b/CHANGES index 3cb975338c..c3e57ded67 100644 --- a/CHANGES +++ b/CHANGES @@ -1,3 +1,9 @@ +4560. [bug] mdig: add -m option to enable memory debugging rather + than have in on all the time. [RT #44509] + +4559. [bug] Openssl_link.c didn't compile if ISC_MEM_TRACKLINES + was turned off. [RT #44509] + 4558. [bug] Synthesised CNAME before matching DNAME was still being cached when it should have been. [RT #44318] diff --git a/bin/tests/mdig.c b/bin/tests/mdig.c index a7bd08a01a..261a93f8ad 100644 --- a/bin/tests/mdig.c +++ b/bin/tests/mdig.c @@ -735,6 +735,7 @@ help(void) { " -6 (use IPv6 query transport only)\n" " -b address[#port] (bind to source address/port)\n" " -p port (specify port number)\n" +" -m (enable memory usage debugging)\n" " +[no]vc (TCP mode)\n" " +[no]tcp (TCP mode, alternate syntax)\n" " +[no]besteffort (Try to parse even illegal messages)\n" @@ -1482,7 +1483,7 @@ plus_option(char *option, struct query *query, isc_boolean_t global) /*% * #ISC_TRUE returned if value was used */ -static const char *single_dash_opts = "46hiv"; +static const char *single_dash_opts = "46himv"; /*static const char *dash_opts = "46bcfhiptvx";*/ static isc_boolean_t dash_option(const char *option, char *next, struct query *query, @@ -1539,6 +1540,11 @@ dash_option(const char *option, char *next, struct query *query, case 'i': query->ip6_int = ISC_TRUE; break; + case 'm': + /* + * handled by preparse_args() + */ + break; case 'v': exit(0); break; @@ -1655,6 +1661,39 @@ clone_default_query() { return query; } +/*% + * Because we may be trying to do memory allocation recording, we're going + * to need to parse the arguments for the -m *before* we start the main + * argument parsing routine. + * + * I'd prefer not to have to do this, but I am not quite sure how else to + * fix the problem. Argument parsing in mdig involves memory allocation + * by its nature, so it can't be done in the main argument parser. + */ +static void +preparse_args(int argc, char **argv) { + int rc; + char **rv; + char *option; + + rc = argc; + rv = argv; + for (rc--, rv++; rc > 0; rc--, rv++) { + if (rv[0][0] != '-') + continue; + option = &rv[0][1]; + while (strpbrk(option, single_dash_opts) == &option[0]) { + switch (option[0]) { + case 'm': + isc_mem_debugging = ISC_MEM_DEBUGTRACE | + ISC_MEM_DEBUGRECORD; + break; + } + option = &option[1]; + } + } +} + static void parse_args(isc_boolean_t is_batchfile, int argc, char **argv) { @@ -1831,8 +1870,9 @@ main(int argc, char *argv[]) { if (!have_ipv4 && !have_ipv6) fatal("could not find either IPv4 or IPv6"); + preparse_args(argc, argv); + mctx = NULL; -isc_mem_debugging = ISC_MEM_DEBUGRECORD; RUNCHECK(isc_mem_create(0, 0, &mctx)); lctx = NULL; diff --git a/lib/dns/openssl_link.c b/lib/dns/openssl_link.c index 0e7009fea9..e6df08a451 100644 --- a/lib/dns/openssl_link.c +++ b/lib/dns/openssl_link.c @@ -131,10 +131,17 @@ id_callback(void) { #endif #if OPENSSL_VERSION_NUMBER < 0x10100000L || defined(LIBRESSL_VERSION_NUMBER) -#define FLARG_PASS , __FILE__, __LINE__ + #define FLARG #define FILELINE +#if ISC_MEM_TRACKLINES +#define FLARG_PASS , __FILE__, __LINE__ #else +#define FLARG_PASS +#endif + +#else + #define FLARG , const char *file, int line #define FILELINE , __FILE__, __LINE__ #if ISC_MEM_TRACKLINES