projects
/
postgresql.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
1f422db
)
Better error reporting if the link target is too long
author
Magnus Hagander
<magnus@hagander.net>
Wed, 7 Dec 2011 11:17:55 +0000
(12:17 +0100)
committer
Magnus Hagander
<magnus@hagander.net>
Wed, 7 Dec 2011 11:19:20 +0000
(12:19 +0100)
This situation won't set errno, so using %m will give an incorrect
error message.
src/backend/utils/adt/misc.c
patch
|
blob
|
blame
|
history
diff --git
a/src/backend/utils/adt/misc.c
b/src/backend/utils/adt/misc.c
index 4453e818c0074fbfc80cfd954202f6bedab5e09a..478f203273fac7ed677e666148a4c5259717022f 100644
(file)
--- 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));