From: tb Date: Fri, 9 Dec 2022 18:22:35 +0000 (+0000) Subject: resolvd: fix leaks of line and fp X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=8475ebac2505d97cb3bdff76dc6b72401d329e63;p=openbsd resolvd: fix leaks of line and fp In case asprintf() fails or the iov overflows, the file and the line read would be leaked. also noted by otto ok deraadt millert --- diff --git a/sbin/resolvd/resolvd.c b/sbin/resolvd/resolvd.c index ff93c31739b..2ffdfc6ddb4 100644 --- a/sbin/resolvd/resolvd.c +++ b/sbin/resolvd/resolvd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: resolvd.c,v 1.31 2022/12/09 18:11:24 otto Exp $ */ +/* $OpenBSD: resolvd.c,v 1.32 2022/12/09 18:22:35 tb Exp $ */ /* * Copyright (c) 2021 Florian Obser * Copyright (c) 2021 Theo de Raadt @@ -654,11 +654,15 @@ regen_resolvconf(const char *why) line); if (len < 0) { lwarn("asprintf"); + free(line); + fclose(fp); goto err; } iov[iovcnt++].iov_len = len; if (iovcnt >= UIO_MAXIOV) { lwarnx("too many user-managed lines"); + free(line); + fclose(fp); goto err; } }