summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authortb <tb@openbsd.org>2021-03-04 15:44:13 +0000
committertb <tb@openbsd.org>2021-03-04 15:44:13 +0000
commit62764b10ff7f19c9445b32c3a784092fd26e9807 (patch)
tree560c41ac9bc171275f432ca0c2affeae8d679c13
parenttypo in comment (diff)
downloadwireguard-openbsd-62764b10ff7f19c9445b32c3a784092fd26e9807.tar.xz
wireguard-openbsd-62764b10ff7f19c9445b32c3a784092fd26e9807.zip
Add two error checks for strdup for consistency.
ok claudio
-rw-r--r--usr.sbin/rpki-client/http.c5
-rw-r--r--usr.sbin/rpki-client/main.c9
2 files changed, 8 insertions, 6 deletions
diff --git a/usr.sbin/rpki-client/http.c b/usr.sbin/rpki-client/http.c
index 82c9a0c2689..867fe2fe29d 100644
--- a/usr.sbin/rpki-client/http.c
+++ b/usr.sbin/rpki-client/http.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: http.c,v 1.4 2021/03/04 14:24:54 claudio Exp $ */
+/* $OpenBSD: http.c,v 1.5 2021/03/04 15:44:13 tb Exp $ */
/*
* Copyright (c) 2020 Nils Fisher <nils_fisher@hotmail.com>
* Copyright (c) 2020 Claudio Jeker <claudio@openbsd.com>
@@ -807,7 +807,8 @@ http_parse_header(struct http_connection *conn, char *buf)
} else if (strncasecmp(cp, LAST_MODIFIED,
sizeof(LAST_MODIFIED) - 1) == 0) {
cp += sizeof(LAST_MODIFIED) - 1;
- conn->last_modified = strdup(cp);
+ if ((conn->last_modified = strdup(cp)) == NULL)
+ err(1, NULL);
}
return 1;
diff --git a/usr.sbin/rpki-client/main.c b/usr.sbin/rpki-client/main.c
index d99676fa020..90f7469da60 100644
--- a/usr.sbin/rpki-client/main.c
+++ b/usr.sbin/rpki-client/main.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: main.c,v 1.113 2021/03/04 15:35:39 claudio Exp $ */
+/* $OpenBSD: main.c,v 1.114 2021/03/04 15:44:13 tb Exp $ */
/*
* Copyright (c) 2019 Kristaps Dzonsons <kristaps@bsd.lv>
*
@@ -590,9 +590,10 @@ queue_add_tal(struct entityq *q, const char *file)
buf = tal_read_file(file);
/* Record tal for later reporting */
- if (stats.talnames == NULL)
- stats.talnames = strdup(file);
- else {
+ if (stats.talnames == NULL) {
+ if ((stats.talnames = strdup(file)) == NULL)
+ err(1, NULL);
+ } else {
char *tmp;
if (asprintf(&tmp, "%s %s", stats.talnames, file) == -1)
err(1, NULL);