In case asprintf() fails or the iov overflows, the file and the line read
would be leaked.
also noted by otto
ok deraadt millert
-/* $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>
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;
}
}