From 62764b10ff7f19c9445b32c3a784092fd26e9807 Mon Sep 17 00:00:00 2001 From: tb Date: Thu, 4 Mar 2021 15:44:13 +0000 Subject: [PATCH] Add two error checks for strdup for consistency. ok claudio --- usr.sbin/rpki-client/http.c | 5 +++-- usr.sbin/rpki-client/main.c | 9 +++++---- 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 * Copyright (c) 2020 Claudio Jeker @@ -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 * @@ -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); -- 2.20.1