mirror of
https://git.postgresql.org/git/postgresql.git
synced 2024-12-15 08:20:16 +08:00
Better error reporting if the link target is too long
This situation won't set errno, so using %m will give an incorrect error message.
This commit is contained in:
parent
1f422db663
commit
0d9b09282f
@ -287,9 +287,12 @@ pg_tablespace_location(PG_FUNCTION_ARGS)
|
||||
*/
|
||||
snprintf(sourcepath, sizeof(sourcepath), "pg_tblspc/%u", tablespaceOid);
|
||||
rllen =readlink(sourcepath, targetpath, sizeof(targetpath));
|
||||
if (rllen < 0 || rllen >= sizeof(targetpath))
|
||||
if (rllen < 0)
|
||||
ereport(ERROR,
|
||||
(errmsg("could not read symbolic link \"%s\": %m", sourcepath)));
|
||||
else if (rllen >= sizeof(targetpath))
|
||||
ereport(ERROR,
|
||||
(errmsg("symbolic link \"%s\" target is too long", sourcepath)));
|
||||
targetpath[rllen] = '\0';
|
||||
|
||||
PG_RETURN_TEXT_P(cstring_to_text(targetpath));
|
||||
|
Loading…
Reference in New Issue
Block a user