From: Bob Halley Date: Mon, 31 Aug 2020 17:01:10 +0000 (-0700) Subject: deal with all zero weight URI case X-Git-Tag: v2.1.0rc1~17^2~4 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=97e0a7b9039f18f51fa5813fcf231b6111da319e;p=thirdparty%2Fdnspython.git deal with all zero weight URI case --- 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)