44a1a2a273
In lib/roken/resolve.c, we find rk_dns_srv_order() which re-orders the results of an SRV RR lookup by the algorithm in RFC2782. We fix a bias in the random weight sorting by changing the order of operations when selecting rnd. rnd should be a non-zero random number less than the sum of the weights at a particular priority, but zero was included as a legitimate output thus biasing the selection process. rk_random() % sum is still biased as a 32 bit int modulo a number which doesn't divide 2^32 does not have a uniform distribution, but the bias should be small enough to live with for our purposes here.