aboutsummaryrefslogtreecommitdiff
path: root/src/backend/utils/misc/tzparser.c
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2022-05-31 14:47:44 -0400
committerTom Lane <tgl@sss.pgh.pa.us>2022-05-31 14:47:44 -0400
commita3faebd6a58aaff0d6521428831041d517db62fe (patch)
treeeb4b9822db26b2a812945437924734e43b281213 /src/backend/utils/misc/tzparser.c
parentfa70c9e0219fe4b8e1a6c35d1425f8fd7772f62d (diff)
downloadpostgresql-a3faebd6a58aaff0d6521428831041d517db62fe.tar.gz
postgresql-a3faebd6a58aaff0d6521428831041d517db62fe.zip
Ensure ParseTzFile() closes the input file after failing.
We hadn't noticed this because (a) few people feed invalid timezone abbreviation files to the server, and (b) in typical scenarios guc.c would throw ereport(ERROR) and then transaction abort handling would silently clean up the leaked file reference. However, it was possible to observe file leakage warnings if one breaks an already-active abbreviation file, because guc.c does not throw ERROR when loading supposedly-validated settings during session start or SIGHUP processing. Report and fix by Kyotaro Horiguchi (cosmetic adjustments by me) Discussion: https://postgr.es/m/20220530.173740.748502979257582392.horikyota.ntt@gmail.com
Diffstat (limited to 'src/backend/utils/misc/tzparser.c')
-rw-r--r--src/backend/utils/misc/tzparser.c23
1 files changed, 16 insertions, 7 deletions
diff --git a/src/backend/utils/misc/tzparser.c b/src/backend/utils/misc/tzparser.c
index cdb9db475d0..b9599f85826 100644
--- a/src/backend/utils/misc/tzparser.c
+++ b/src/backend/utils/misc/tzparser.c
@@ -365,7 +365,8 @@ ParseTzFile(const char *filename, int depth,
{
GUC_check_errmsg("could not read time zone file \"%s\": %m",
filename);
- return -1;
+ n = -1;
+ break;
}
/* else we're at EOF after all */
break;
@@ -375,7 +376,8 @@ ParseTzFile(const char *filename, int depth,
/* the line is too long for tzbuf */
GUC_check_errmsg("line is too long in time zone file \"%s\", line %d",
filename, lineno);
- return -1;
+ n = -1;
+ break;
}
/* skip over whitespace */
@@ -398,12 +400,13 @@ ParseTzFile(const char *filename, int depth,
{
GUC_check_errmsg("@INCLUDE without file name in time zone file \"%s\", line %d",
filename, lineno);
- return -1;
+ n = -1;
+ break;
}
n = ParseTzFile(includeFile, depth + 1,
base, arraysize, n);
if (n < 0)
- return -1;
+ break;
continue;
}
@@ -414,12 +417,18 @@ ParseTzFile(const char *filename, int depth,
}
if (!splitTzLine(filename, lineno, line, &tzentry))
- return -1;
+ {
+ n = -1;
+ break;
+ }
if (!validateTzEntry(&tzentry))
- return -1;
+ {
+ n = -1;
+ break;
+ }
n = addToArray(base, arraysize, n, &tzentry, override);
if (n < 0)
- return -1;
+ break;
}
FreeFile(tzFile);