From 8af0b86ade4c15a7db207bd7643f8a9f6cb5a648 Mon Sep 17 00:00:00 2001 From: David Lawrence Date: Thu, 10 Aug 2000 02:32:14 +0000 Subject: [PATCH] 384. [bug] nsupdate was incorrectly limiting TTLs to 65535 instead of 2147483647. --- CHANGES | 2 ++ bin/nsupdate/nsupdate.c | 31 ++++++++++++++++++++----------- 2 files changed, 22 insertions(+), 11 deletions(-) diff --git a/CHANGES b/CHANGES index fb0d6d3ced..422cc3c6c3 100644 --- a/CHANGES +++ b/CHANGES @@ -1,3 +1,5 @@ + 384. [bug] nsupdate was incorrectly limiting TTLs to 65535 instead + of 2147483647. 383. [func] When writing a master file, print the SOA and NS records (and their SIGs) before other records. diff --git a/bin/nsupdate/nsupdate.c b/bin/nsupdate/nsupdate.c index d609ec0375..39438ad601 100644 --- a/bin/nsupdate/nsupdate.c +++ b/bin/nsupdate/nsupdate.c @@ -15,10 +15,17 @@ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: nsupdate.c,v 1.42 2000/08/09 18:44:13 bwelling Exp $ */ +/* $Id: nsupdate.c,v 1.43 2000/08/10 02:32:14 tale Exp $ */ #include +#include +#include +#include +#include +#include +#include + #include #include #include @@ -57,11 +64,6 @@ #include #include -#include -#include -#include -#include - #define MXNAME 256 #define MAXCMD 1024 #define NAMEBUF 512 @@ -69,6 +71,7 @@ #define PACKETSIZE 2048 #define MSGTEXT 4096 #define FIND_TIMEOUT 5 +#define TTL_MAX 2147483647 /* Maximum signed 32 bit integer. */ #define DNSDEFAULTPORT 53 @@ -826,7 +829,7 @@ update_addordelete(char *cmdline, isc_boolean_t isdelete) { ddebug("update_addordelete()"); /* - * Read the owner name + * Read the owner name. */ retval = parse_name(&cmdline, updatemsg, &name); if (retval != STATUS_MORE) @@ -850,12 +853,18 @@ update_addordelete(char *cmdline, isc_boolean_t isdelete) { goto failure; } ttl = strtol(word, &endp, 0); - if (*endp != 0) { + if (*endp != '\0') { fprintf(stderr, "ttl '%s' is not numeric\n", word); goto failure; - } else if (ttl < 1 || ttl > 65535) { + } else if (ttl < 1 || ttl > TTL_MAX || errno == ERANGE) { + /* + * The errno test is needed to catch when strtol() + * overflows on a platform where sizeof(int) == + * sizeof(long), because ttl will be set to LONG_MAX, + * which will be equal to TTL_MAX. + */ fprintf(stderr, "ttl '%s' is out of range " - "(1 to 65535)\n", word); + "(1 to %d)\n", word, TTL_MAX); goto failure; } } else @@ -930,7 +939,7 @@ update_addordelete(char *cmdline, isc_boolean_t isdelete) { rdatalist->type = rdatatype; rdatalist->rdclass = rdataclass; rdatalist->covers = rdatatype; - rdatalist->ttl = (isc_uint16_t)ttl; + rdatalist->ttl = (dns_ttl_t)ttl; ISC_LIST_INIT(rdatalist->rdata); ISC_LIST_APPEND(rdatalist->rdata, rdata, link); dns_rdataset_init(rdataset);