diff options
author | Claudio Jeker <claudio@cvs.openbsd.org> | 2021-03-04 14:24:18 +0000 |
---|---|---|
committer | Claudio Jeker <claudio@cvs.openbsd.org> | 2021-03-04 14:24:18 +0000 |
commit | 27ce01674b7b6ef35e806f47736b4403b33a023d (patch) | |
tree | a28e32881fc98969a762ae0aeaddbeb2e4d576c9 /usr.sbin | |
parent | 68d6ecaafeb2e7518c98919e2f1a5fee21ac9a0d (diff) |
Use the same way to error out in out of memory situation.
Just use 'err(1, NULL);' there is no need to include the type of function
that failed since it is still impossible to locate the right call.
Just use a debugger in that case.
OK tb@ deraadt@
Diffstat (limited to 'usr.sbin')
-rw-r--r-- | usr.sbin/rpki-client/main.c | 39 | ||||
-rw-r--r-- | usr.sbin/rpki-client/mft.c | 4 | ||||
-rw-r--r-- | usr.sbin/rpki-client/rsync.c | 6 |
3 files changed, 24 insertions, 25 deletions
diff --git a/usr.sbin/rpki-client/main.c b/usr.sbin/rpki-client/main.c index 399cfcadd15..3187627fa09 100644 --- a/usr.sbin/rpki-client/main.c +++ b/usr.sbin/rpki-client/main.c @@ -1,4 +1,4 @@ -/* $OpenBSD: main.c,v 1.111 2021/03/04 14:16:21 tb Exp $ */ +/* $OpenBSD: main.c,v 1.112 2021/03/04 14:24:17 claudio Exp $ */ /* * Copyright (c) 2019 Kristaps Dzonsons <kristaps@bsd.lv> * @@ -232,7 +232,7 @@ entityq_add(struct entityq *q, char *file, enum rtype type, struct entity *p; if ((p = calloc(1, sizeof(struct entity))) == NULL) - err(1, "calloc"); + err(1, NULL); p->type = type; p->file = file; @@ -241,12 +241,12 @@ entityq_add(struct entityq *q, char *file, enum rtype type, if (p->has_pkey) { p->pkeysz = pkeysz; if ((p->pkey = malloc(pkeysz)) == NULL) - err(1, "malloc"); + err(1, NULL); memcpy(p->pkey, pkey, pkeysz); } if (descr != NULL) if ((p->descr = strdup(descr)) == NULL) - err(1, "strdup"); + err(1, NULL); filepath_add(file); @@ -275,7 +275,7 @@ repo_alloc(void) rt.repos = recallocarray(rt.repos, rt.reposz, rt.reposz + 1, sizeof(struct repo)); if (rt.repos == NULL) - err(1, "recallocarray"); + err(1, NULL); rp = &rt.repos[rt.reposz++]; rp->id = rt.reposz - 1; @@ -398,7 +398,7 @@ ta_lookup(const struct tal *tal) size_t i, j; if (asprintf(&local, "ta/%s", tal->descr) == -1) - err(1, "asprinf"); + err(1, NULL); /* Look up in repository table. (Lookup should actually fail here) */ for (i = 0; i < rt.reposz; i++) { @@ -412,7 +412,7 @@ ta_lookup(const struct tal *tal) rp->local = local; for (i = 0, j = 0; i < tal->urisz && j < 2; i++) { if ((rp->uris[j++] = strdup(tal->uri[i])) == NULL) - err(1, "strdup"); + err(1, NULL); } if (j == 0) errx(1, "TAL %s has no URI", tal->descr); @@ -446,10 +446,10 @@ repo_lookup(const char *uri) rp = repo_alloc(); rp->repouri = repo; local = strchr(repo, ':') + strlen("://"); - if (asprintf(&rp->local, "rsync/%s", local) == -1) - err(1, "asprintf"); + if ((rp->local = strdup(repo)) == NULL) + err(1, NULL); if ((rp->uris[0] = strdup(repo)) == NULL) - err(1, "strdup"); + err(1, NULL); repo_fetch(rp); return rp; @@ -467,7 +467,7 @@ ta_filename(const struct repo *repo, int temp) if (asprintf(&nfile, "%s%s%s", repo->local, file, temp ? ".XXXXXXXX": "") == -1) - err(1, "asprintf"); + err(1, NULL); return nfile; } @@ -485,7 +485,7 @@ repo_filename(const struct repo *repo, const char *uri) uri += strlen(repo->repouri) + 1; /* skip base and '/' */ if (asprintf(&nfile, "%s/%s", repo->local, uri) == -1) - err(1, "asprintf"); + err(1, NULL); return nfile; } @@ -504,7 +504,7 @@ queue_add_from_mft(struct entityq *q, const char *mft, assert(cp != NULL); assert(cp - mft < INT_MAX); if (asprintf(&nfile, "%.*s/%s", (int)(cp - mft), mft, file->file) == -1) - err(1, "asprintf"); + err(1, NULL); /* * Since we're from the same directory as the MFT file, we know @@ -586,7 +586,7 @@ queue_add_tal(struct entityq *q, const char *file) char *nfile, *buf; if ((nfile = strdup(file)) == NULL) - err(1, "strdup"); + err(1, NULL); buf = tal_read_file(file); /* Record tal for later reporting */ @@ -595,7 +595,7 @@ queue_add_tal(struct entityq *q, const char *file) else { char *tmp; if (asprintf(&tmp, "%s %s", stats.talnames, file) == -1) - err(1, "asprintf"); + err(1, NULL); free(stats.talnames); stats.talnames = tmp; } @@ -760,7 +760,7 @@ tal_load_default(const char *tals[], size_t max) err(1, "too many tal files found in %s", confdir); if (asprintf(&path, "%s/%s", confdir, dp->d_name) == -1) - err(1, "asprintf"); + err(1, NULL); tals[s++] = path; } closedir (dirp); @@ -774,10 +774,9 @@ add_to_del(char **del, size_t *dsz, char *file) del = reallocarray(del, i + 1, sizeof(*del)); if (del == NULL) - err(1, "reallocarray"); - del[i] = strdup(file); - if (del[i] == NULL) - err(1, "strdup"); + err(1, NULL); + if ((del[i] = strdup(file)) == NULL) + err(1, NULL); *dsz = i + 1; return del; } diff --git a/usr.sbin/rpki-client/mft.c b/usr.sbin/rpki-client/mft.c index 45c801cf6df..04944b79369 100644 --- a/usr.sbin/rpki-client/mft.c +++ b/usr.sbin/rpki-client/mft.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mft.c,v 1.27 2021/02/19 12:18:23 tb Exp $ */ +/* $OpenBSD: mft.c,v 1.28 2021/03/04 14:24:17 claudio Exp $ */ /* * Copyright (c) 2019 Kristaps Dzonsons <kristaps@bsd.lv> * @@ -452,7 +452,7 @@ mft_validfilehash(const char *fn, const struct mftfile *m) assert(cp != NULL); assert(cp - fn < INT_MAX); if (asprintf(&path, "%.*s/%s", (int)(cp - fn), fn, m->file) == -1) - err(1, "asprintf"); + err(1, NULL); if ((fd = open(path, O_RDONLY)) == -1) { warn("%s: referenced file %s", fn, m->file); diff --git a/usr.sbin/rpki-client/rsync.c b/usr.sbin/rpki-client/rsync.c index 206475c54cc..e1c9cd71de6 100644 --- a/usr.sbin/rpki-client/rsync.c +++ b/usr.sbin/rpki-client/rsync.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rsync.c,v 1.20 2021/03/04 14:02:34 claudio Exp $ */ +/* $OpenBSD: rsync.c,v 1.21 2021/03/04 14:24:17 claudio Exp $ */ /* * Copyright (c) 2019 Kristaps Dzonsons <kristaps@bsd.lv> * @@ -141,13 +141,13 @@ proc_rsync(char *prog, char *bind_addr, int fd) if (getenv("PATH") == NULL) errx(1, "PATH is unset"); if ((path = strdup(getenv("PATH"))) == NULL) - err(1, "strdup"); + err(1, NULL); save = path; while ((pp = strsep(&path, ":")) != NULL) { if (*pp == '\0') continue; if (asprintf(&cmd, "%s/%s", pp, prog) == -1) - err(1, "asprintf"); + err(1, NULL); if (lstat(cmd, &stt) == -1) { free(cmd); continue; |