From d0a542515549a71fa2fb7456326ab99c378d929a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Ekl=C3=B6f?= Date: Tue, 23 Jul 2024 12:15:29 +0200 Subject: [PATCH] notify: add_icon(): check return value of write() --- notify.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/notify.c b/notify.c index 9a9311ee..f8c2bfe1 100644 --- a/notify.c +++ b/notify.c @@ -303,11 +303,14 @@ add_icon(struct notification_icon *icon, const char *id, const char *symbolic_na return; } - write(fd, data, data_sz); - close(fd); + if (write(fd, data, data_sz) != (ssize_t)data_sz) { + LOG_ERRNO("failed to write icon data to temporary file"); + } else { + LOG_DBG("wrote icon data to %s", name); + icon->tmp_file_on_disk = xstrdup(name); + } - LOG_DBG("wrote icon data to %s", name); - icon->tmp_file_on_disk = xstrdup(name); + close(fd); } LOG_DBG("added icon to cache: ID=%s: sym=%s, file=%s",