From 7e4968974681e63ac84d6309f66a30aa05d7618f Mon Sep 17 00:00:00 2001 From: Mark Andrews Date: Thu, 13 Aug 2020 14:13:49 +1000 Subject: [PATCH] X25: Check that record is all ASCII digits --- lib/dns/rdata/generic/x25_19.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/dns/rdata/generic/x25_19.c b/lib/dns/rdata/generic/x25_19.c index 4c53621478..93f99c8dc6 100644 --- a/lib/dns/rdata/generic/x25_19.c +++ b/lib/dns/rdata/generic/x25_19.c @@ -59,6 +59,7 @@ totext_x25(ARGS_TOTEXT) { static inline isc_result_t fromwire_x25(ARGS_FROMWIRE) { isc_region_t sr; + unsigned int i; REQUIRE(type == dns_rdatatype_x25); @@ -68,9 +69,14 @@ fromwire_x25(ARGS_FROMWIRE) { UNUSED(options); isc_buffer_activeregion(source, &sr); - if (sr.length < 5) { + if (sr.length < 5 || sr.base[0] != (sr.length - 1)) { return (DNS_R_FORMERR); } + for (i = 1; i < sr.length; i++) { + if (sr.base[i] < 0x30 || sr.base[i] > 0x39) { + return (DNS_R_FORMERR); + } + } return (txt_fromwire(source, target)); }