From 6955a1d66c26343443a22f488b9f662aa240d010 Mon Sep 17 00:00:00 2001 From: Sami Kerola Date: Sun, 25 Jun 2017 01:35:28 +0100 Subject: [PATCH] rfkill: do not ignore read error Read error should be impossible, but when one does happen user certainly wants to know about that rather than see even more strange issue caused random data in name variable. Signed-off-by: Sami Kerola --- sys-utils/rfkill.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/sys-utils/rfkill.c b/sys-utils/rfkill.c index e0671ffecf..717506950f 100644 --- a/sys-utils/rfkill.c +++ b/sys-utils/rfkill.c @@ -132,7 +132,11 @@ static const char *get_name(uint32_t idx) return NULL; } - read(fd, name, sizeof(name) - 1); + if (read(fd, name, sizeof(name) - 1) < 0) { + warn(_("cannot read %s"), filename); + close(fd); + return NULL; + } pos = strchr(name, '\n'); if (pos) -- 2.47.3