]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
rfkill: do not ignore read error
authorSami Kerola <kerolasa@iki.fi>
Sun, 25 Jun 2017 00:35:28 +0000 (01:35 +0100)
committerSami Kerola <kerolasa@iki.fi>
Wed, 30 Aug 2017 19:32:48 +0000 (20:32 +0100)
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>
sys-utils/rfkill.c

index e0671ffecf55ad20b6bdac42d258df38a257cd82..717506950f73c4fbe929d5d4282889c915a3d20f 100644 (file)
@@ -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)