Skip to content
Snippets Groups Projects
Commit 0d9b0928 authored by Magnus Hagander's avatar Magnus Hagander
Browse files

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.
parent 1f422db6
No related branches found
No related tags found
No related merge requests found
......@@ -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));
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment