summaryrefslogtreecommitdiffstats
path: root/lib/common/io.c
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--lib/common/io.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/lib/common/io.c b/lib/common/io.c
index 2264e16..35efbe9 100644
--- a/lib/common/io.c
+++ b/lib/common/io.c
@@ -460,11 +460,17 @@ pcmk__file_contents(const char *filename, char **contents)
goto bail;
}
rewind(fp);
- read_len = fread(*contents, 1, length, fp); /* Coverity: False positive */
+
+ read_len = fread(*contents, 1, length, fp);
if (read_len != length) {
free(*contents);
*contents = NULL;
rc = EIO;
+ } else {
+ /* Coverity thinks *contents isn't null-terminated. It doesn't
+ * understand calloc().
+ */
+ (*contents)[length] = '\0';
}
}