1
0
mirror of https://github.com/postgrespro/pg_probackup.git synced 2025-02-12 14:56:08 +02:00

Fix inconsistency in call of readlink()

If the target path is too long, an error needs to be emitted as well.
The buffer is correctly null-terminated, this will just avoid running
into weird problems should the target have a too long name.
This commit is contained in:
Michael Paquier 2016-01-20 13:13:32 +09:00
parent b84334b8f3
commit 1ae2feb38f

8
dir.c
View File

@ -292,11 +292,13 @@ dir_list_file_internal(parray *files, const char *root, const char *exclude[],
char linked[MAXPGPATH];
len = readlink(file->path, linked, sizeof(linked));
if (len == -1)
{
if (len < 0)
elog(ERROR, "cannot read link \"%s\": %s", file->path,
strerror(errno));
}
if (len >= sizeof(linked))
elog(ERROR, "symbolic link \"%s\" target is too long\n",
file->path);
linked[len] = '\0';
file->linked = pgut_strdup(linked);