summaryrefslogtreecommitdiffstats
path: root/src/policy.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/policy.c')
-rw-r--r--src/policy.c15
1 files changed, 13 insertions, 2 deletions
diff --git a/src/policy.c b/src/policy.c
index aae99a1..47a64f1 100644
--- a/src/policy.c
+++ b/src/policy.c
@@ -53,13 +53,13 @@ int authz_split_ws(char *line, char **f, int max)
p++;
if (*p == '\0')
break;
+ if (n == max)
+ return n + 1; // "too many"; the caller decides
f[n++] = p;
while (*p != '\0' && !isspace((unsigned char)*p))
p++;
if (*p != '\0')
*p++ = '\0';
- if (n == max)
- return n + 1; // "too many"; the caller decides
}
return n;
}
@@ -323,6 +323,17 @@ int policy_load(policy_t *p)
parse_rule(p, text, lineno);
}
free(line);
+ // A read that stopped because the file would not give an answer is not an
+ // empty policy: a directory, an I/O error halfway, a mount pulled out. The
+ // lines read so far are not the file, so this is the broken-host answer (3),
+ // not the empty-policy answer (0).
+ if (ferror(f)) {
+ fclose(f);
+ p->unreadable = 1;
+ fprintf(stderr, "%s: cannot read the policy: ", p->path);
+ perror("");
+ return -2;
+ }
fclose(f);
return p->errors > 0 ? -1 : 0;
}