8000 Better error reporting if the link target is too long · postgres/postgres@0d9b092 · GitHub
[go: up one dir, main page]

Skip to content
  • Commit 0d9b092

    Browse files
    committed
    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.
    1 parent 1f422db commit 0d9b092

    File tree

    1 file changed

    +4
    -1
    lines changed

    1 file changed

    +4
    -1
    lines changed

    src/backend/utils/adt/misc.c

    Lines changed: 4 additions & 1 deletion
    Original file line numberDiff line numberDiff line change
    @@ -287,9 +287,12 @@ pg_tablespace_location(PG_FUNCTION_ARGS)
    287287
    */
    288288
    snprintf(sourcepath, sizeof(sourcepath), "pg_tblspc/%u", tablespaceOid);
    289289
    rllen =readlink(sourcepath, targetpath, sizeof(targetpath));
    290-
    if (rllen < 0 || rllen >= sizeof(targetpath))
    290+
    if (rllen < 0)
    291291
    ereport(ERROR,
    292292
    (errmsg("could not read symbolic link \"%s\": %m", sourcepath)));
    293+
    else if (rllen >= sizeof(targetpath))
    294+
    ereport(ERROR,
    295+
    (errmsg("symbolic link \"%s\" target is too long", sourcepath)));
    293296
    targetpath[rllen] = '\0';
    294297

    295298
    PG_RETURN_TEXT_P(cstring_to_text(targetpath));

    0 commit comments

    Comments
     (0)
    0