From 23cb957a81a51a9656917ea98d0ae56b7abdcacc Mon Sep 17 00:00:00 2001 From: Mark Andrews Date: Tue, 12 Feb 2002 03:45:54 +0000 Subject: [PATCH] 1201. [bug] Require that if 'callbacks' is passed to dns_rdata_fromtext(), callbacks->error and callbacks->warn are initalised. --- CHANGES | 4 ++++ lib/dns/include/dns/rdata.h | 5 ++++- lib/dns/rdata.c | 39 +++++++++++++++---------------------- 3 files changed, 24 insertions(+), 24 deletions(-) diff --git a/CHANGES b/CHANGES index b2b8572a0f..8bd4b04fb7 100644 --- a/CHANGES +++ b/CHANGES @@ -1,3 +1,7 @@ +1201. [bug] Require that if 'callbacks' is passed to + dns_rdata_fromtext(), callbacks->error and + callbacks->warn are initalised. + 1200. [bug] Log 'errno' that we are unable to convert to isc_result_t. [RT #2404] diff --git a/lib/dns/include/dns/rdata.h b/lib/dns/include/dns/rdata.h index 66281245f0..3a007eac98 100644 --- a/lib/dns/include/dns/rdata.h +++ b/lib/dns/include/dns/rdata.h @@ -15,7 +15,7 @@ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: rdata.h,v 1.51 2001/04/30 18:09:30 gson Exp $ */ +/* $Id: rdata.h,v 1.52 2002/02/12 03:45:54 marka Exp $ */ #ifndef DNS_RDATA_H #define DNS_RDATA_H 1 @@ -319,6 +319,9 @@ dns_rdata_fromtext(dns_rdata_t *rdata, dns_rdataclass_t rdclass, * 'target' is a valid region. * * 'origin' if non NULL it must be absolute. + * + * 'callbacks' to be NULL or callbacks->warn and callbacks->error be + * initalised. * * Ensures: * If result is success: diff --git a/lib/dns/rdata.c b/lib/dns/rdata.c index 349224d804..3e0090fcc8 100644 --- a/lib/dns/rdata.c +++ b/lib/dns/rdata.c @@ -15,7 +15,7 @@ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: rdata.c,v 1.159 2002/02/11 22:30:28 marka Exp $ */ +/* $Id: rdata.c,v 1.160 2002/02/12 03:45:52 marka Exp $ */ #include #include @@ -193,19 +193,12 @@ getquad(const void *src, struct in_addr *dst, result = inet_aton(src, dst); if (result == 1 && callbacks != NULL && inet_pton(AF_INET, src, &tmp) != 1) { - void (*callback)(dns_rdatacallbacks_t *, const char *, ...); - const char *name; - - if (callbacks != NULL && callbacks->warn != NULL) - callback = callbacks->warn; - else - callback = default_fromtext_callback; - name = isc_lex_getsourcename(lexer); + const char *name = isc_lex_getsourcename(lexer); if (name == NULL) name = "UNKNOWN"; - (*callback)(callbacks, "%s:%lu: warning \"%s\" " - "is not a decimal dotted quad", name, - isc_lex_getsourceline(lexer), src); + (*callbacks->warn)(callbacks, "%s:%lu: warning \"%s\" " + "is not a decimal dotted quad", name, + isc_lex_getsourceline(lexer), src); } return (result); } @@ -686,10 +679,14 @@ dns_rdata_fromtext(dns_rdata_t *rdata, dns_rdataclass_t rdclass, REQUIRE(DNS_RDATA_INITIALIZED(rdata)); REQUIRE(DNS_RDATA_VALIDFLAGS(rdata)); } + if (callbacks != NULL) { + REQUIRE(callbacks->warn != NULL); + REQUIRE(callbacks->error != NULL); + } st = *target; - if (callbacks != NULL && callbacks->error != NULL) + if (callbacks != NULL) callback = callbacks->error; else callback = default_fromtext_callback; @@ -1945,16 +1942,12 @@ default_fromtext_callback(dns_rdatacallbacks_t *callbacks, const char *fmt, static void fromtext_warneof(isc_lex_t *lexer, dns_rdatacallbacks_t *callbacks) { if (isc_lex_isfile(lexer) && callbacks != NULL) { - void (*callback)(dns_rdatacallbacks_t *, const char *, ...); - - if (callbacks->warn != NULL) - callback = callbacks->warn; - else - callback = default_fromtext_callback; - (*callback)(callbacks, - "%s:%lu: file does not end with newline", - isc_lex_getsourcename(lexer), - isc_lex_getsourceline(lexer)); + const char *name = isc_lex_getsourcename(lexer); + if (name == NULL) + name = "UNKNOWN"; + (*callbacks->warn)(callbacks, + "%s:%lu: file does not end with newline", + name, isc_lex_getsourceline(lexer)); } }