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>
This commit is contained in:
Sami Kerola 2017-06-25 01:35:28 +01:00
parent b03378e793
commit 6955a1d66c
No known key found for this signature in database
GPG Key ID: A9553245FDE9B739
1 changed files with 5 additions and 1 deletions

View 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)