Detect file truncation earlier in a few places

Users of read_one_line_file() for APIVFS entries are ignored as they are
assumed to never get truncated.
This commit is contained in:
Topi Miettinen
2019-02-02 16:25:32 +02:00
parent cbed254f96
commit a21760454d
3 changed files with 5 additions and 5 deletions
+2 -2
View File
@@ -147,8 +147,8 @@ static int load_state(Context *c, const struct rfkill_event *event) {
return r;
r = read_one_line_file(state_file, &value);
if (r == -ENOENT) {
/* No state file? Then save the current state */
if (IN_SET(r, -ENOENT, 0)) {
/* No state file or it's truncated? Then save the current state */
r = write_string_file(state_file, one_zero(event->soft), WRITE_STRING_FILE_CREATE|WRITE_STRING_FILE_ATOMIC);
if (r < 0)