From 2c9db9314993504064c1a71f4a059ff9493a75ca Mon Sep 17 00:00:00 2001 From: Brian Wellington Date: Thu, 29 Mar 2001 23:51:36 +0000 Subject: [PATCH] 798. [bug] nsupdate should be able to reject bad input lines and continue. [RT #1130] --- CHANGES | 3 +++ bin/nsupdate/nsupdate.c | 31 +++++++++++++++++++++---------- 2 files changed, 24 insertions(+), 10 deletions(-) diff --git a/CHANGES b/CHANGES index 391eee464a..5ec36e305f 100644 --- a/CHANGES +++ b/CHANGES @@ -1,3 +1,6 @@ + 798. [bug] nsupdate should be able to reject bad input lines + and continue. [RT #1130] + 797. [func] Issue a warning if the 'directory' option contains a relative path. [RT #269] diff --git a/bin/nsupdate/nsupdate.c b/bin/nsupdate/nsupdate.c index 3033909719..364a72aef7 100644 --- a/bin/nsupdate/nsupdate.c +++ b/bin/nsupdate/nsupdate.c @@ -15,7 +15,7 @@ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: nsupdate.c,v 1.85 2001/03/28 02:42:51 bwelling Exp $ */ +/* $Id: nsupdate.c,v 1.86 2001/03/29 23:51:36 bwelling Exp $ */ #include @@ -747,10 +747,12 @@ parse_rdata(char **cmdlinep, dns_rdataclass_t rdataclass, bufsz *= 2; isc_lex_destroy(&lex); } while (result == ISC_R_NOSPACE); - check_result(result, "dns_rdata_fromtext"); dns_message_takebuffer(msg, &buf); - if (result != ISC_R_SUCCESS) - return (STATUS_MORE); + if (result != ISC_R_SUCCESS) { + fprintf(stderr, "invalid rdata format: %s\n", + isc_result_totext(result)); + return (STATUS_SYNTAX); + } } else { rdata->flags = DNS_RDATA_UPDATE; } @@ -787,8 +789,7 @@ make_prereq(char *cmdline, isc_boolean_t ispositive, isc_boolean_t isrrset) { word = nsu_strsep(&cmdline, " \t\r\n"); if (*word == 0) { fprintf(stderr, "failed to read class or type\n"); - dns_message_puttempname(updatemsg, &name); - return (STATUS_SYNTAX); + goto failure; } region.base = word; region.length = strlen(word); @@ -800,17 +801,22 @@ make_prereq(char *cmdline, isc_boolean_t ispositive, isc_boolean_t isrrset) { word = nsu_strsep(&cmdline, " \t\r\n"); if (*word == 0) { fprintf(stderr, "failed to read type\n"); - dns_message_puttempname(updatemsg, &name); - return (STATUS_SYNTAX); + goto failure; } region.base = word; region.length = strlen(word); result = dns_rdatatype_fromtext(&rdatatype, ®ion); - check_result(result, "dns_rdatatype_fromtext"); + if (result != ISC_R_SUCCESS) { + fprintf(stderr, "invalid type: %s\n"); + goto failure; + } } else { rdataclass = dns_rdataclass_in; result = dns_rdatatype_fromtext(&rdatatype, ®ion); - check_result(result, "dns_rdatatype_fromtext"); + if (result != ISC_R_SUCCESS) { + fprintf(stderr, "invalid type: %s\n"); + goto failure; + } } } else rdatatype = dns_rdatatype_any; @@ -853,6 +859,11 @@ make_prereq(char *cmdline, isc_boolean_t ispositive, isc_boolean_t isrrset) { ISC_LIST_APPEND(name->list, rdataset, link); dns_message_addname(updatemsg, name, DNS_SECTION_PREREQUISITE); return (STATUS_MORE); + + failure: + if (name != NULL) + dns_message_puttempname(updatemsg, &name); + return (STATUS_SYNTAX); } static isc_uint16_t