diff options
author | Magnus Hagander <magnus@hagander.net> | 2011-12-07 12:17:55 +0100 |
---|---|---|
committer | Magnus Hagander <magnus@hagander.net> | 2011-12-07 12:19:20 +0100 |
commit | 0d9b09282fbf2a21160d57d2f11785cb23841909 (patch) | |
tree | 511194535a79f3621f3076f2efe683e29e053cf7 /src/backend/utils/adt/misc.c | |
parent | 1f422db663aa291be4af4b079e7d1b0ef0d78af2 (diff) | |
download | postgresql-0d9b09282fbf2a21160d57d2f11785cb23841909.tar.gz postgresql-0d9b09282fbf2a21160d57d2f11785cb23841909.zip |
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.
Diffstat (limited to 'src/backend/utils/adt/misc.c')
-rw-r--r-- | src/backend/utils/adt/misc.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/src/backend/utils/adt/misc.c b/src/backend/utils/adt/misc.c index 4453e818c00..478f203273f 100644 --- a/src/backend/utils/adt/misc.c +++ b/src/backend/utils/adt/misc.c @@ -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)); |