From 97e0a7b9039f18f51fa5813fcf231b6111da319e Mon Sep 17 00:00:00 2001 From: Bob Halley Date: Mon, 31 Aug 2020 10:01:10 -0700 Subject: [PATCH] deal with all zero weight URI case --- dns/rdtypes/util.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/dns/rdtypes/util.py b/dns/rdtypes/util.py index c2fb6038..ddc4c672 100644 --- a/dns/rdtypes/util.py +++ b/dns/rdtypes/util.py @@ -240,6 +240,11 @@ def weighted_processing_order(iterable, adjust_zero_weight=False): weight = _processing_weight(rdata, adjust_zero_weight) weights.remove(weight) ordered.append(rdatas[0]) + elif weights[0] == 0: + # All the weights are 0! (This can't happen with SRV, but + # can with URI. It's not clear from the URI RFC what you do here + # as it doesn't discuss weight. + return [] else: random.shuffle(rdatas) ordered.extend(rdatas) -- 2.47.3