summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSami Kerola2017-06-25 02:35:28 +0200
committerSami Kerola2017-08-30 21:32:48 +0200
commit6955a1d66c26343443a22f488b9f662aa240d010 (patch)
treebb7f0560bd45edf1a8b2333c05359e7c305d161c
parentrfkill: clarify 'all devices' handling (diff)
downloadkernel-qcow2-util-linux-6955a1d66c26343443a22f488b9f662aa240d010.tar.gz
kernel-qcow2-util-linux-6955a1d66c26343443a22f488b9f662aa240d010.tar.xz
kernel-qcow2-util-linux-6955a1d66c26343443a22f488b9f662aa240d010.zip
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 <kerolasa@iki.fi>
-rw-r--r--sys-utils/rfkill.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/sys-utils/rfkill.c b/sys-utils/rfkill.c
index e0671ffec..717506950 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)