diff options
author | Theo Buehler <tb@cvs.openbsd.org> | 2022-12-09 18:22:36 +0000 |
---|---|---|
committer | Theo Buehler <tb@cvs.openbsd.org> | 2022-12-09 18:22:36 +0000 |
commit | 7e549a340378296e132be677a5f70a14fb4b4ed9 (patch) | |
tree | 0305cf1dc12eea5fe81e75fc65876a661120ce51 /sbin | |
parent | cbcf4c4eb34a9db7c1fc374c5fd2759aa5efcc0c (diff) |
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
Diffstat (limited to 'sbin')
-rw-r--r-- | sbin/resolvd/resolvd.c | 6 |
1 files changed, 5 insertions, 1 deletions
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 <florian@openbsd.org> * Copyright (c) 2021 Theo de Raadt <deraadt@openbsd.org> @@ -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; } } |