From 4cf64648daeeb98d787716dbbe90c04ff3441967 Mon Sep 17 00:00:00 2001 From: Mark Andrews Date: Tue, 14 Jan 2014 16:06:45 +1100 Subject: [PATCH] 3704. [protocol] Accept integer timestamps in RRSIG records. [RT #35185] --- CHANGES | 2 ++ lib/dns/rdata/generic/rrsig_46.c | 28 ++++++++++++++++++++++++++-- 2 files changed, 28 insertions(+), 2 deletions(-) diff --git a/CHANGES b/CHANGES index d466baae13..f4aed8e5c1 100644 --- a/CHANGES +++ b/CHANGES @@ -1,3 +1,5 @@ +3704. [protocol] Accept integer timestamps in RRSIG records. [RT #35185] + --- 9.6-ESV-R11rc1 released --- 3698. [cleanup] Replaced all uses of memcpy() with memmove(). diff --git a/lib/dns/rdata/generic/rrsig_46.c b/lib/dns/rdata/generic/rrsig_46.c index 5b761d85fe..b450fed77f 100644 --- a/lib/dns/rdata/generic/rrsig_46.c +++ b/lib/dns/rdata/generic/rrsig_46.c @@ -90,7 +90,19 @@ fromtext_rrsig(ARGS_FROMTEXT) { */ RETERR(isc_lex_getmastertoken(lexer, &token, isc_tokentype_string, ISC_FALSE)); - RETTOK(dns_time32_fromtext(DNS_AS_STR(token), &time_expire)); + if (strlen(DNS_AS_STR(token)) <= 10U && + *DNS_AS_STR(token) != '-' && *DNS_AS_STR(token) != '+') { + char *end; + unsigned long l; + + l = strtoul(DNS_AS_STR(token), &end, 10); + if (l == ULONG_MAX || *end != 0) + RETTOK(DNS_R_SYNTAX); + if ((isc_uint64_t)l > (isc_uint64_t)0xffffffff) + RETTOK(ISC_R_RANGE); + time_expire = l; + } else + RETTOK(dns_time32_fromtext(DNS_AS_STR(token), &time_expire)); RETERR(uint32_tobuffer(time_expire, target)); /* @@ -98,7 +110,19 @@ fromtext_rrsig(ARGS_FROMTEXT) { */ RETERR(isc_lex_getmastertoken(lexer, &token, isc_tokentype_string, ISC_FALSE)); - RETTOK(dns_time32_fromtext(DNS_AS_STR(token), &time_signed)); + if (strlen(DNS_AS_STR(token)) <= 10U && + *DNS_AS_STR(token) != '-' && *DNS_AS_STR(token) != '+') { + char *end; + unsigned long l; + + l = strtoul(DNS_AS_STR(token), &end, 10); + if (l == ULONG_MAX || *end != 0) + RETTOK(DNS_R_SYNTAX); + if ((isc_uint64_t)l > (isc_uint64_t)0xffffffff) + RETTOK(ISC_R_RANGE); + time_signed = l; + } else + RETTOK(dns_time32_fromtext(DNS_AS_STR(token), &time_signed)); RETERR(uint32_tobuffer(time_signed, target)); /*