2
0
mirror of https://gitlab.isc.org/isc-projects/bind9 synced 2025-09-01 06:55:30 +00:00

1109. [bug] nsupdate accepted illegal ttl values.

e.g. "update add foo -0 IN A 1.2.3.4"
simlified ttl range processing by using unsigned long.
This commit is contained in:
Mark Andrews
2001-11-07 04:44:09 +00:00
parent a89d1aea0c
commit 3842a051ba
2 changed files with 8 additions and 15 deletions

View File

@@ -1,3 +1,5 @@
1109. [bug] nsupdate accepted illegal ttl values.
1108. [bug] On Win32 rndc was hanging when named was not running. 1108. [bug] On Win32 rndc was hanging when named was not running.
Fix to look for exceptions in the socket.c select Fix to look for exceptions in the socket.c select
code to catch and report the errors. Miscellaneous code to catch and report the errors. Miscellaneous

View File

@@ -15,7 +15,7 @@
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/ */
/* $Id: nsupdate.c,v 1.111 2001/11/06 20:21:42 gson Exp $ */ /* $Id: nsupdate.c,v 1.112 2001/11/07 04:44:09 marka Exp $ */
#include <config.h> #include <config.h>
@@ -1101,7 +1101,7 @@ static isc_uint16_t
update_addordelete(char *cmdline, isc_boolean_t isdelete) { update_addordelete(char *cmdline, isc_boolean_t isdelete) {
isc_result_t result; isc_result_t result;
dns_name_t *name = NULL; dns_name_t *name = NULL;
long ttl; unsigned long ttl;
char *word; char *word;
dns_rdataclass_t rdataclass; dns_rdataclass_t rdataclass;
dns_rdatatype_t rdatatype; dns_rdatatype_t rdatatype;
@@ -1147,29 +1147,20 @@ update_addordelete(char *cmdline, isc_boolean_t isdelete) {
goto doneparsing; goto doneparsing;
} }
} }
errno = 0; ttl = strtoul(word, &endp, 0);
ttl = strtol(word, &endp, 0); if (!isdigit((unsigned char)*word) || *endp != '\0') {
if (*endp != '\0') {
if (isdelete) { if (isdelete) {
ttl = 0; ttl = 0;
goto parseclass; goto parseclass;
} else { } else {
fprintf(stderr, "ttl '%s' is not numeric\n", word); fprintf(stderr, "ttl '%s' is not legal\n", word);
goto failure; goto failure;
} }
} }
if (isdelete) if (isdelete)
ttl = 0; ttl = 0;
else if (ttl < 0 || ttl > TTL_MAX || else if (ttl > TTL_MAX) {
(ttl == LONG_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 (0 to %d)\n", fprintf(stderr, "ttl '%s' is out of range (0 to %d)\n",
word, TTL_MAX); word, TTL_MAX);
goto failure; goto failure;