From 6f6c5cbbb8ab46e1157f5706bc5fbe2966166720 Mon Sep 17 00:00:00 2001 From: otto Date: Fri, 9 Dec 2022 18:11:24 +0000 Subject: [PATCH] iovcnt can be zero, writev does not like that and O_CREATE is not needed, we just renamed sucessfully to that file. ok deraadt@ florian@ --- sbin/resolvd/resolvd.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/sbin/resolvd/resolvd.c b/sbin/resolvd/resolvd.c index 9260a6254ab..ff93c31739b 100644 --- a/sbin/resolvd/resolvd.c +++ b/sbin/resolvd/resolvd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: resolvd.c,v 1.30 2022/11/27 15:19:38 kn Exp $ */ +/* $OpenBSD: resolvd.c,v 1.31 2022/12/09 18:11:24 otto Exp $ */ /* * Copyright (c) 2021 Florian Obser * Copyright (c) 2021 Theo de Raadt @@ -666,9 +666,11 @@ regen_resolvconf(const char *why) fclose(fp); } - if (writev(fd, iov, iovcnt) == -1) { - lwarn("writev"); - goto err; + if (iovcnt > 0) { + if (writev(fd, iov, iovcnt) == -1) { + lwarn("writev"); + goto err; + } } if (fsync(fd) == -1) { @@ -680,7 +682,7 @@ regen_resolvconf(const char *why) if (resolvfd == -1) { close(fd); - resolvfd = open(_PATH_RESCONF, O_RDWR | O_CREAT); + resolvfd = open(_PATH_RESCONF, O_RDWR); } else { dup2(fd, resolvfd); close(fd); -- 2.20.1