+
+ return NULL;
+}
+
+static char *slurp_text_file(const char *path) {
+ struct stat stat;
+ size_t size_read;
+ char *content = NULL;
+
+ FILE *file = fopen(path, "r");
+ if (file == NULL) {
+ return NULL;
+ }
+
+ ct_assert(sizeof(stat.st_size) <= sizeof(size_t));
+
+ if (fstat(fileno(file), &stat) != 0) {
+ goto out;
+ }
+ if (stat.st_size < 0) { /* just in case ... */
+ abort();
+ } else if ((size_t)stat.st_size >= SIZE_MAX - 1) {
+ errno = 0;
+ goto out;
+ }
+
+ content = malloc((size_t)stat.st_size + 1);
+ if (content == NULL) {
+ goto out;
+ }
+
+ errno = 0;
+ size_read = fread(content, 1, (size_t)stat.st_size, file);
+ if (size_read != (size_t)stat.st_size) {
+ free(content);
+ content = NULL;
+ goto out;
+ }
+ content[size_read] = '\0';
+
+out:
+ fclose(file);
+
+ return content;