1
0
mirror of https://github.com/postgrespro/pg_probackup.git synced 2025-01-24 11:46:31 +02:00

check for potential errors when fgets() returns NULL

This commit is contained in:
Grigory Smolkin 2019-08-27 19:24:10 +03:00
parent b95a1589a4
commit aef926ffd0
3 changed files with 18 additions and 0 deletions

View File

@ -514,6 +514,9 @@ dir_list_file(parray *files, const char *root, bool exclude, bool follow_symlink
parray_append(black_list, pgut_strdup(black_item));
}
if (ferror(black_list_file))
elog(ERROR, "Failed to read from file: \"%s\"", path);
fio_close_stream(black_list_file);
parray_qsort(black_list, BlackListCompare);
}
@ -1154,6 +1157,9 @@ read_tablespace_map(parray *files, const char *backup_dir)
parray_append(files, file);
}
if (ferror(fp))
elog(ERROR, "Failed to read from file: \"%s\"", map_path);
fio_close_stream(fp);
}
@ -1529,6 +1535,9 @@ dir_read_file_list(const char *root, const char *external_prefix,
parray_append(files, file);
}
if (ferror(fp))
elog(ERROR, "Failed to read from file: \"%s\"", file_txt);
fio_close_stream(fp);
return files;
}
@ -1775,6 +1784,9 @@ read_database_map(pgBackup *backup)
parray_append(database_map, db_entry);
}
if (ferror(fp))
elog(ERROR, "Failed to read from file: \"%s\"", database_map_path);
fio_close_stream(fp);
/* Return NULL if file is empty */

View File

@ -996,6 +996,9 @@ read_timeline_history(TimeLineID targetTLI)
/* we ignore the remainder of each line */
}
if (fd && (ferror(fd)))
elog(ERROR, "Failed to read from file: \"%s\"", path);
if (fd)
fclose(fd);

View File

@ -523,6 +523,9 @@ config_read_opt(const char *path, ConfigOption options[], int elevel,
}
}
if (ferror(fp))
elog(ERROR, "Failed to read from file: \"%s\"", path);
fio_close_stream(fp);
return parsed_options;