aboutsummaryrefslogtreecommitdiff
path: root/usr.sbin
diff options
context:
space:
mode:
authorKyle Evans <kevans@FreeBSD.org>2021-02-12 00:58:27 +0000
committerKyle Evans <kevans@FreeBSD.org>2021-02-12 00:58:27 +0000
commitb2c4ca8d2872bc4410626f2b1ceafa49de5828ce (patch)
tree9859236eb057507f3bfb1b91c0d17de075f78a2a /usr.sbin
parent18418e1936b59c34a9c4a02a1ba5fe0d00dde1b3 (diff)
Diffstat (limited to 'usr.sbin')
-rw-r--r--usr.sbin/pkg/dns_utils.c5
-rw-r--r--usr.sbin/pkg/pkg.c3
2 files changed, 3 insertions, 5 deletions
diff --git a/usr.sbin/pkg/dns_utils.c b/usr.sbin/pkg/dns_utils.c
index 78ebdd426f8b..f3bde529daca 100644
--- a/usr.sbin/pkg/dns_utils.c
+++ b/usr.sbin/pkg/dns_utils.c
@@ -87,7 +87,7 @@ compute_weight(struct dns_srvinfo **d, int first, int last)
int *chosen;
totalweight = 0;
-
+
for (i = 0; i <= last; i++)
totalweight += d[i]->weight;
@@ -98,7 +98,8 @@ compute_weight(struct dns_srvinfo **d, int first, int last)
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
index 5e424cf83034..1f787e3dd246 100644
--- a/usr.sbin/pkg/pkg.c
+++ b/usr.sbin/pkg/pkg.c
@@ -434,9 +434,7 @@ sha256_fd(int fd, char out[SHA256_DIGEST_LENGTH * 2 + 1])
int ret;
SHA256_CTX sha256;
- my_fd = -1;
fp = NULL;
- r = 0;
ret = 1;
out[0] = '\0';
@@ -627,7 +625,6 @@ parse_cert(int fd) {
ssize_t linelen;
buf = NULL;
- my_fd = -1;
sc = NULL;
line = NULL;
linecap = 0;