Skip to content

s:snprintf(..., MAXPGPATH, "%s/%s", ...):join_path_components(...):g #393

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 7, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/catalog.c
Original file line number Diff line number Diff line change
Expand Up @@ -829,7 +829,7 @@ IsDir(const char *dirpath, const char *entry, fio_location location)
char path[MAXPGPATH];
struct stat st;

snprintf(path, MAXPGPATH, "%s/%s", dirpath, entry);
join_path_components(path, dirpath, entry);

return fio_stat(path, &st, false, location) == 0 && S_ISDIR(st.st_mode);
}
Expand Down Expand Up @@ -941,7 +941,7 @@ catalog_get_backup_list(const char *instance_name, time_t requested_backup_id)
join_path_components(data_path, backup_instance_path, data_ent->d_name);

/* read backup information from BACKUP_CONTROL_FILE */
snprintf(backup_conf_path, MAXPGPATH, "%s/%s", data_path, BACKUP_CONTROL_FILE);
join_path_components(backup_conf_path, data_path, BACKUP_CONTROL_FILE);
backup = readBackupControlFile(backup_conf_path);

if (!backup)
Expand Down
2 changes: 1 addition & 1 deletion src/parsexlog.c
Original file line number Diff line number Diff line change
Expand Up @@ -1017,7 +1017,7 @@ SimpleXLogPageRead(XLogReaderState *xlogreader, XLogRecPtr targetPagePtr,

GetXLogFileName(xlogfname, reader_data->tli, reader_data->xlogsegno, wal_seg_size);

snprintf(reader_data->xlogpath, MAXPGPATH, "%s/%s", wal_archivedir, xlogfname);
join_path_components(reader_data->xlogpath, wal_archivedir, xlogfname);
snprintf(reader_data->gz_xlogpath, MAXPGPATH, "%s.gz", reader_data->xlogpath);

/* We fall back to using .partial segment in case if we are running
Expand Down
13 changes: 6 additions & 7 deletions src/restore.c
Original file line number Diff line number Diff line change
Expand Up @@ -1480,7 +1480,7 @@ update_recovery_options_before_v12(pgBackup *backup,
}

elog(LOG, "update recovery settings in recovery.conf");
snprintf(path, lengthof(path), "%s/recovery.conf", instance_config.pgdata);
join_path_components(path, instance_config.pgdata, "recovery.conf");

fp = fio_fopen(path, "w", FIO_DB_HOST);
if (fp == NULL)
Expand Down Expand Up @@ -1537,8 +1537,7 @@ update_recovery_options(pgBackup *backup,

time2iso(current_time_str, lengthof(current_time_str), current_time, false);

snprintf(postgres_auto_path, lengthof(postgres_auto_path),
"%s/postgresql.auto.conf", instance_config.pgdata);
join_path_components(postgres_auto_path, instance_config.pgdata, "postgresql.auto.conf");

if (fio_stat(postgres_auto_path, &st, false, FIO_DB_HOST) < 0)
{
Expand Down Expand Up @@ -1648,7 +1647,7 @@ update_recovery_options(pgBackup *backup,
if (params->recovery_settings_mode == PITR_REQUESTED)
{
elog(LOG, "creating recovery.signal file");
snprintf(path, lengthof(path), "%s/recovery.signal", instance_config.pgdata);
join_path_components(path, instance_config.pgdata, "recovery.signal");

fp = fio_fopen(path, PG_BINARY_W, FIO_DB_HOST);
if (fp == NULL)
Expand All @@ -1664,7 +1663,7 @@ update_recovery_options(pgBackup *backup,
if (params->restore_as_replica)
{
elog(LOG, "creating standby.signal file");
snprintf(path, lengthof(path), "%s/standby.signal", instance_config.pgdata);
join_path_components(path, instance_config.pgdata, "standby.signal");

fp = fio_fopen(path, PG_BINARY_W, FIO_DB_HOST);
if (fp == NULL)
Expand Down Expand Up @@ -2160,7 +2159,7 @@ check_incremental_compatibility(const char *pgdata, uint64 system_identifier,
{
char pid_file[MAXPGPATH];

snprintf(pid_file, MAXPGPATH, "%s/postmaster.pid", pgdata);
join_path_components(pid_file, pgdata, "postmaster.pid");
elog(WARNING, "Pid file \"%s\" is mangled, cannot determine whether postmaster is running or not",
pid_file);
success = false;
Expand Down Expand Up @@ -2201,7 +2200,7 @@ check_incremental_compatibility(const char *pgdata, uint64 system_identifier,
*/
if (incremental_mode == INCR_LSN)
{
snprintf(backup_label, MAXPGPATH, "%s/backup_label", pgdata);
join_path_components(backup_label, pgdata, "backup_label");
if (fio_access(backup_label, F_OK, FIO_DB_HOST) == 0)
{
elog(WARNING, "Destination directory contains \"backup_control\" file. "
Expand Down
4 changes: 2 additions & 2 deletions src/util.c
Original file line number Diff line number Diff line change
Expand Up @@ -418,7 +418,7 @@ set_min_recovery_point(pgFile *file, const char *backup_path,
FIN_CRC32C(ControlFile.crc);

/* overwrite pg_control */
snprintf(fullpath, sizeof(fullpath), "%s/%s", backup_path, XLOG_CONTROL_FILE);
join_path_components(fullpath, backup_path, XLOG_CONTROL_FILE);
writeControlFile(&ControlFile, fullpath, FIO_LOCAL_HOST);

/* Update pg_control checksum in backup_list */
Expand Down Expand Up @@ -569,7 +569,7 @@ check_postmaster(const char *pgdata)
pid_t pid;
char pid_file[MAXPGPATH];

snprintf(pid_file, MAXPGPATH, "%s/postmaster.pid", pgdata);
join_path_components(pid_file, pgdata, "postmaster.pid");

fp = fopen(pid_file, "r");
if (fp == NULL)
Expand Down
2 changes: 1 addition & 1 deletion src/utils/pgut.c
Original file line number Diff line number Diff line change
Expand Up @@ -1184,7 +1184,7 @@ pgut_rmtree(const char *path, bool rmtopdir, bool strict)
/* now we have the names we can start removing things */
for (filename = filenames; *filename; filename++)
{
snprintf(pathbuf, MAXPGPATH, "%s/%s", path, *filename);
join_path_components(pathbuf, path, *filename);

if (lstat(pathbuf, &statbuf) != 0)
{
Expand Down