From a7a431551857bf3c39ec3226ce764c18e8585cf3 Mon Sep 17 00:00:00 2001 From: tb Date: Mon, 13 Dec 2021 19:47:40 +0000 Subject: [PATCH] Fix asprintf() error check. Portable code should check the return value for -1, not buf == NULL. ok tobhe --- sbin/iked/ca.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/sbin/iked/ca.c b/sbin/iked/ca.c index e1d457f8935..4c8ec89d1c4 100644 --- a/sbin/iked/ca.c +++ b/sbin/iked/ca.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ca.c,v 1.85 2021/12/13 19:46:22 tb Exp $ */ +/* $OpenBSD: ca.c,v 1.86 2021/12/13 19:47:40 tb Exp $ */ /* * Copyright (c) 2010-2013 Reyk Floeter @@ -1133,7 +1133,7 @@ ca_store_info(struct iked *env, const char *msg, X509_STORE *ctx) X509_NAME *subject; char *name; char *buf; - size_t buflen; + int buflen; h = X509_STORE_get0_objects(ctx); for (i = 0; i < sk_X509_OBJECT_num(h); i++) { @@ -1146,7 +1146,7 @@ ca_store_info(struct iked *env, const char *msg, X509_STORE *ctx) continue; buflen = asprintf(&buf, "%s: %s\n", msg, name); free(name); - if (buf == NULL) + if (buflen == -1) continue; proc_compose(&env->sc_ps, PROC_CONTROL, IMSG_CTL_SHOW_CERTSTORE, buf, buflen + 1); -- 2.20.1