Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitb76e76b

Browse files
committed
Detect setlocale(LC_CTYPE, NULL) clobbering previous return values.
POSIX permits setlocale() calls to invalidate any previous setlocale()return values. Commit5f538adneglected to account for that. In advance of fixing that bug, switch tofailing hard on affected configurations. This is a planned temporarycommit to assay buildfarm-represented configurations.
1 parent41d798a commitb76e76b

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

‎src/backend/utils/adt/pg_locale.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@
5858
#include"catalog/pg_collation.h"
5959
#include"catalog/pg_control.h"
6060
#include"mb/pg_wchar.h"
61+
#include"utils/builtins.h"
6162
#include"utils/hsearch.h"
6263
#include"utils/memutils.h"
6364
#include"utils/pg_locale.h"
@@ -148,6 +149,7 @@ pg_perm_setlocale(int category, const char *locale)
148149
char*result;
149150
constchar*envvar;
150151
char*envbuf;
152+
charorig_result[LC_ENV_BUFSIZE];
151153

152154
#ifndefWIN32
153155
result=setlocale(category,locale);
@@ -173,6 +175,7 @@ pg_perm_setlocale(int category, const char *locale)
173175

174176
if (result==NULL)
175177
returnresult;/* fall out immediately on failure */
178+
strlcpy(orig_result,result,sizeof(orig_result));
176179

177180
/*
178181
* Use the right encoding in translated messages. Under ENABLE_NLS, let
@@ -231,6 +234,17 @@ pg_perm_setlocale(int category, const char *locale)
231234
}
232235

233236
snprintf(envbuf,LC_ENV_BUFSIZE-1,"%s=%s",envvar,result);
237+
if (strcmp(orig_result,result)!=0)
238+
{
239+
charhex[2*LC_ENV_BUFSIZE+1];
240+
unsignedhexlen;
241+
242+
hexlen=
243+
hex_encode(result,Min(1+strlen(result),LC_ENV_BUFSIZE),hex);
244+
hex[hexlen]='\0';
245+
elog(FATAL,"setlocale() result %s clobbered to 0x%s",
246+
orig_result,hex);
247+
}
234248

235249
if (putenv(envbuf))
236250
returnNULL;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp