diff --git a/usr.sbin/pkg/dns_utils.c b/usr.sbin/pkg/dns_utils.c --- a/usr.sbin/pkg/dns_utils.c +++ b/usr.sbin/pkg/dns_utils.c @@ -87,7 +87,7 @@ int *chosen; totalweight = 0; - + for (i = 0; i <= last; i++) totalweight += d[i]->weight; @@ -98,7 +98,8 @@ for (i = 0; i <= last; i++) { for (;;) { - chosen[i] = random() % (d[i]->weight * 100 / totalweight); + chosen[i] = arc4random_uniform(d[i]->weight * 100 / + totalweight); for (j = 0; j < i; j++) { if (chosen[i] == chosen[j]) break; diff --git a/usr.sbin/pkg/pkg.c b/usr.sbin/pkg/pkg.c --- a/usr.sbin/pkg/pkg.c +++ b/usr.sbin/pkg/pkg.c @@ -434,9 +434,7 @@ int ret; SHA256_CTX sha256; - my_fd = -1; fp = NULL; - r = 0; ret = 1; out[0] = '\0'; @@ -627,7 +625,6 @@ ssize_t linelen; buf = NULL; - my_fd = -1; sc = NULL; line = NULL; linecap = 0;