diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2017-06-23 16:00:45 -0400 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2017-06-23 16:00:55 -0400 |
commit | d1fcc622987c1a5b490b956d89f36ac9fed8f9d1 (patch) | |
tree | 50319457bd0a6df3d10c25f0eba08e71c9903b88 /src/backend/commands/collationcmds.c | |
parent | 08859bb5c2cebc132629ca838113d27bb31b990c (diff) | |
download | postgresql-d1fcc622987c1a5b490b956d89f36ac9fed8f9d1.tar.gz postgresql-d1fcc622987c1a5b490b956d89f36ac9fed8f9d1.zip |
Fix incorrect buffer-length argument to uloc_getDisplayName().
The maxResultSize argument of uloc_getDisplayName is the number of
UChars in the output buffer, not the number of bytes. In principle
this could result in a stack smash, although at least in my Fedora 25
install there are no ICU locales with display names long enough to
overrun the buffer. But it's easily proven to be wrong by reducing
the length of displayname to around 20, whereupon a stack smash
does happen.
(This is a rather scary bug, because the same mistake could easily
have been made in other places; but in a quick code search looking
at uses of UChar I could not find any other instances.)
Diffstat (limited to 'src/backend/commands/collationcmds.c')
-rw-r--r-- | src/backend/commands/collationcmds.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/src/backend/commands/collationcmds.c b/src/backend/commands/collationcmds.c index a0b3b238163..1c43f0b0ed9 100644 --- a/src/backend/commands/collationcmds.c +++ b/src/backend/commands/collationcmds.c @@ -443,7 +443,7 @@ get_icu_locale_comment(const char *localename) status = U_ZERO_ERROR; len_uchar = uloc_getDisplayName(localename, "en", - &displayname[0], sizeof(displayname), + displayname, lengthof(displayname), &status); if (U_FAILURE(status)) ereport(ERROR, |