*/
if (relative_path == NULL)
{
- strncpy(ifulldir, input_directory, MAXPGPATH);
- strncpy(ofulldir, output_directory, MAXPGPATH);
+ strlcpy(ifulldir, input_directory, MAXPGPATH);
+ strlcpy(ofulldir, output_directory, MAXPGPATH);
if (OidIsValid(tsoid))
snprintf(manifest_prefix, MAXPGPATH, "pg_tblspc/%u/", tsoid);
else
/* Append new pathname component to relative path. */
if (relative_path == NULL)
- strncpy(new_relative_path, de->d_name, MAXPGPATH);
+ strlcpy(new_relative_path, de->d_name, MAXPGPATH);
else
snprintf(new_relative_path, MAXPGPATH, "%s/%s", relative_path,
de->d_name);
pg_log_debug("scanning \"%s\"", pg_tblspc);
if ((dir = opendir(pg_tblspc)) == NULL)
- pg_fatal("could not open directory \"%s\": %m", pathname);
+ pg_fatal("could not open directory \"%s\": %m", pg_tblspc);
while (errno = 0, (de = readdir(dir)) != NULL)
{
{
if (strcmp(tsmap->old_dir, link_target) == 0)
{
- strncpy(ts->old_dir, tsmap->old_dir, MAXPGPATH);
- strncpy(ts->new_dir, tsmap->new_dir, MAXPGPATH);
+ strlcpy(ts->old_dir, tsmap->old_dir, MAXPGPATH);
+ strlcpy(ts->new_dir, tsmap->new_dir, MAXPGPATH);
ts->in_place = false;
break;
}
tslist = ts;
}
+ if (closedir(dir) != 0)
+ pg_fatal("could not close directory \"%s\": %m", pg_tblspc);
+
return tslist;
}
{
if (current_block == start_of_range)
appendStringInfo(&debug_buf, " %u:%s@" UINT64_FORMAT,
- current_block,
- s == NULL ? "ZERO" : s->filename,
+ current_block, s->filename,
(uint64) offsetmap[current_block]);
else
appendStringInfo(&debug_buf, " %u-%u:%s@" UINT64_FORMAT,
start_of_range, current_block,
- s == NULL ? "ZERO" : s->filename,
+ s->filename,
(uint64) offsetmap[current_block]);
}
static void
flush_manifest(manifest_writer *mwriter)
{
- char pathname[MAXPGPATH];
-
if (mwriter->fd == -1 &&
(mwriter->fd = open(mwriter->pathname,
O_WRONLY | O_CREAT | O_EXCL | PG_BINARY,
pg_fatal("could not write \"%s\": %m", mwriter->pathname);
else
pg_fatal("could not write file \"%s\": wrote only %d of %d bytes",
- pathname, (int) wb, mwriter->buf.len);
+ mwriter->pathname, (int) wb, mwriter->buf.len);
}
- if (mwriter->still_checksumming)
+ if (mwriter->still_checksumming &&
pg_checksum_update(&mwriter->manifest_ctx,
(uint8 *) mwriter->buf.data,
- mwriter->buf.len);
+ mwriter->buf.len) < 0)
+ pg_fatal("could not update checksum of file \"%s\"",
+ mwriter->pathname);
resetStringInfo(&mwriter->buf);
}
}