-/* $OpenBSD: encoding.c,v 1.1 2021/04/01 06:43:23 claudio Exp $ */
+/* $OpenBSD: encoding.c,v 1.2 2021/04/19 17:04:35 deraadt Exp $ */
/*
* Copyright (c) 2020 Claudio Jeker <claudio@openbsd.org>
*
-/* $OpenBSD: http.c,v 1.30 2021/04/15 16:07:21 claudio Exp $ */
+/* $OpenBSD: http.c,v 1.31 2021/04/19 17:04:35 deraadt Exp $ */
/*
* Copyright (c) 2020 Nils Fisher <nils_fisher@hotmail.com>
* Copyright (c) 2020 Claudio Jeker <claudio@openbsd.org>
{
struct http_connection *http_conns[MAX_CONNECTIONS];
struct pollfd pfds[MAX_CONNECTIONS + 1];
- size_t i;
- int active_connections;
if (bind_addr != NULL) {
struct addrinfo hints, *res;
msgq.fd = fd;
for (;;) {
- active_connections = 0;
+ int active_connections = 0;
+ size_t i;
+
for (i = 0; i < MAX_CONNECTIONS; i++) {
struct http_connection *conn = http_conns[i];
-/* $OpenBSD: ip.c,v 1.16 2021/03/29 06:15:29 deraadt Exp $ */
+/* $OpenBSD: ip.c,v 1.17 2021/04/19 17:04:35 deraadt Exp $ */
/*
* Copyright (c) 2019 Kristaps Dzonsons <kristaps@bsd.lv>
*
size_t i, sz = ip->afi == AFI_IPV4 ? 4 : 16;
int inherit_v4 = 0, inherit_v6 = 0;
int has_v4 = 0, has_v6 = 0, socktype;
- char buf[64];
/*
* FIXME: cache this by having a flag on the cert_ip, else we're
/* Check our ranges. */
for (i = 0; i < ipsz; i++) {
+ char buf[64];
+
if (ips[i].afi != ip->afi)
continue;
if (memcmp(ips[i].max, ip->min, sz) <= 0 ||
-/* $OpenBSD: main.c,v 1.138 2021/04/15 14:22:05 claudio Exp $ */
+/* $OpenBSD: main.c,v 1.139 2021/04/19 17:04:35 deraadt Exp $ */
/*
* Copyright (c) 2019 Kristaps Dzonsons <kristaps@bsd.lv>
*
struct entity *p, *np;
TAILQ_FOREACH_SAFE(p, q, entries, np) {
+ char *file = p->file;
+
/*
* XXX fixup path here since the repo may change
* during load because of fallback. In that case
* the file path changes as well since RRDP and RSYNC
* can not share a common repo.
*/
- char *file = p->file;
p->file = repo_filename(rp, file);
if (p->file == NULL)
err(1, "can't construct repo filename");
err(1, NULL);
} else {
char *tmp;
+
if (asprintf(&tmp, "%s %s", stats.talnames, file) == -1)
err(1, NULL);
free(stats.talnames);
-/* $OpenBSD: output-bgpd.c,v 1.20 2021/03/29 03:39:14 deraadt Exp $ */
+/* $OpenBSD: output-bgpd.c,v 1.21 2021/04/19 17:04:35 deraadt Exp $ */
/*
* Copyright (c) 2019 Kristaps Dzonsons <kristaps@bsd.lv>
*
int
output_bgpd(FILE *out, struct vrp_tree *vrps, struct stats *st)
{
- char ipbuf[64], maxlenbuf[100];
struct vrp *v;
if (outputheader(out, st) < 0)
return -1;
RB_FOREACH(v, vrp_tree, vrps) {
+ char ipbuf[64], maxlenbuf[100];
+
ip_addr_print(&v->addr, v->afi, ipbuf, sizeof(ipbuf));
if (v->maxlength > v->addr.prefixlen) {
int ret = snprintf(maxlenbuf, sizeof(maxlenbuf),
-/* $OpenBSD: output-bird.c,v 1.10 2020/09/12 15:46:48 claudio Exp $ */
+/* $OpenBSD: output-bird.c,v 1.11 2021/04/19 17:04:35 deraadt Exp $ */
/*
* Copyright (c) 2019 Claudio Jeker <claudio@openbsd.org>
* Copyright (c) 2020 Robert Scheck <robert@fedoraproject.org>
output_bird1v4(FILE *out, struct vrp_tree *vrps, struct stats *st)
{
extern const char *bird_tablename;
- char buf[64];
struct vrp *v;
if (outputheader(out, st) < 0)
return -1;
RB_FOREACH(v, vrp_tree, vrps) {
+ char buf[64];
+
if (v->afi == AFI_IPV4) {
ip_addr_print(&v->addr, v->afi, buf, sizeof(buf));
if (fprintf(out, "\troa %s max %u as %u;\n", buf,
output_bird1v6(FILE *out, struct vrp_tree *vrps, struct stats *st)
{
extern const char *bird_tablename;
- char buf[64];
struct vrp *v;
if (outputheader(out, st) < 0)
return -1;
RB_FOREACH(v, vrp_tree, vrps) {
+ char buf[64];
+
if (v->afi == AFI_IPV6) {
ip_addr_print(&v->addr, v->afi, buf, sizeof(buf));
if (fprintf(out, "\troa %s max %u as %u;\n", buf,
output_bird2(FILE *out, struct vrp_tree *vrps, struct stats *st)
{
extern const char *bird_tablename;
- char buf[64];
struct vrp *v;
time_t now = time(NULL);
return -1;
RB_FOREACH(v, vrp_tree, vrps) {
+ char buf[64];
+
if (v->afi == AFI_IPV4) {
ip_addr_print(&v->addr, v->afi, buf, sizeof(buf));
if (fprintf(out, "\troute %s max %u as %u;\n", buf,
return -1;
RB_FOREACH(v, vrp_tree, vrps) {
+ char buf[64];
+
if (v->afi == AFI_IPV6) {
ip_addr_print(&v->addr, v->afi, buf, sizeof(buf));
if (fprintf(out, "\troute %s max %u as %u;\n", buf,
-/* $OpenBSD: output-csv.c,v 1.8 2020/09/12 15:46:48 claudio Exp $ */
+/* $OpenBSD: output-csv.c,v 1.9 2021/04/19 17:04:35 deraadt Exp $ */
/*
* Copyright (c) 2019 Claudio Jeker <claudio@openbsd.org>
*
int
output_csv(FILE *out, struct vrp_tree *vrps, struct stats *st)
{
- char buf[64];
struct vrp *v;
if (fprintf(out, "ASN,IP Prefix,Max Length,Trust Anchor\n") < 0)
return -1;
RB_FOREACH(v, vrp_tree, vrps) {
+ char buf[64];
+
ip_addr_print(&v->addr, v->afi, buf, sizeof(buf));
if (fprintf(out, "AS%u,%s,%u,%s\n", v->asid, buf, v->maxlength,
v->tal) < 0)
-/* $OpenBSD: repo.c,v 1.5 2021/04/13 13:35:59 claudio Exp $ */
+/* $OpenBSD: repo.c,v 1.6 2021/04/19 17:04:35 deraadt Exp $ */
/*
* Copyright (c) 2021 Claudio Jeker <claudio@openbsd.org>
* Copyright (c) 2019 Kristaps Dzonsons <kristaps@bsd.lv>
static void
ta_fetch(struct tarepo *tr)
{
- int fd;
-
logx("ta/%s: pulling from %s", tr->descr, tr->uri[tr->uriidx]);
if (strncasecmp(tr->uri[tr->uriidx], "rsync://", 8) == 0) {
*/
rsync_fetch(tr->id, tr->uri[tr->uriidx], tr->basedir);
} else {
+ int fd;
+
tr->temp = ta_filename(tr, 1);
fd = mkostemp(tr->temp, O_CLOEXEC);
if (fd == -1) {
{
size_t i, delsz = 0, dirsz = 0;
char **del = NULL, **dir = NULL;
- char *argv[4];
+ char *argv[4] = { "ta", "rsync", "rrdp", NULL };
FTS *fts;
FTSENT *e;
- argv[0] = "ta";
- argv[1] = "rsync";
- argv[2] = "rrdp";
- argv[3] = NULL;
if ((fts = fts_open(argv, FTS_PHYSICAL | FTS_NOSTAT, NULL)) == NULL)
err(1, "fts_open");
errno = 0;
-/* $OpenBSD: rrdp.c,v 1.5 2021/04/15 13:31:30 claudio Exp $ */
+/* $OpenBSD: rrdp.c,v 1.6 2021/04/19 17:04:35 deraadt Exp $ */
/*
* Copyright (c) 2020 Nils Fisher <nils_fisher@hotmail.com>
* Copyright (c) 2021 Claudio Jeker <claudio@openbsd.org>
-/* $OpenBSD: rsync.c,v 1.23 2021/04/01 11:04:30 job Exp $ */
+/* $OpenBSD: rsync.c,v 1.24 2021/04/19 17:04:35 deraadt Exp $ */
/*
* Copyright (c) 2019 Kristaps Dzonsons <kristaps@bsd.lv>
*
void
proc_rsync(char *prog, char *bind_addr, int fd)
{
- size_t id, i, idsz = 0;
- ssize_t ssz;
- char *uri = NULL, *dst = NULL, *path, *save, *cmd;
- const char *pp;
- pid_t pid;
- char *args[32];
- int st, rc = 0;
- struct stat stt;
+ size_t i, idsz = 0;
+ int rc = 0;
struct pollfd pfd;
struct msgbuf msgq;
- struct ibuf *b;
sigset_t mask, oldmask;
struct rsyncproc *ids = NULL;
*/
if (strchr(prog, '/') == NULL) {
+ const char *pp;
+ char *save, *cmd, *path;
+ struct stat stt;
+
if (getenv("PATH") == NULL)
errx(1, "PATH is unset");
if ((path = strdup(getenv("PATH"))) == NULL)
err(1, NULL);
for (;;) {
+ char *uri = NULL, *dst = NULL;
+ ssize_t ssz;
+ size_t id;
+ pid_t pid;
+ int st;
+
pfd.events = POLLIN;
if (msgq.queued)
pfd.events |= POLLOUT;
*/
while ((pid = waitpid(WAIT_ANY, &st, WNOHANG)) > 0) {
+ struct ibuf *b;
int ok = 1;
for (i = 0; i < idsz; i++)
err(1, "fork");
if (pid == 0) {
+ char *args[32];
+
if (pledge("stdio exec", NULL) == -1)
err(1, "pledge");
i = 0;
args[i++] = uri;
args[i++] = dst;
args[i] = NULL;
+ /* XXX args overflow not prevented */
execvp(args[0], args);
err(1, "%s: execvp", prog);
}
-/* $OpenBSD: validate.c,v 1.13 2021/03/05 17:15:19 claudio Exp $ */
+/* $OpenBSD: validate.c,v 1.14 2021/04/19 17:04:35 deraadt Exp $ */
/*
* Copyright (c) 2019 Kristaps Dzonsons <kristaps@bsd.lv>
*
/* Does this certificate cover our AS number? */
if (a->cert->asz) {
- c = as_check_covered(min, max,
- a->cert->as, a->cert->asz);
+ c = as_check_covered(min, max, a->cert->as, a->cert->asz);
if (c > 0)
return 1;
else if (c < 0)
return 0;
/* Does this certificate cover our IP prefix? */
- c = ip_addr_check_covered(afi, min, max,
- a->cert->ips, a->cert->ipsz);
+ c = ip_addr_check_covered(afi, min, max, a->cert->ips, a->cert->ipsz);
if (c > 0)
return 1;
else if (c < 0)