Skip to content

Commit e790528

Browse files
macdicepull[bot]
authored andcommitted
Remove obsolete defense against strxfrm() bugs.
Old versions of Solaris and illumos had buffer overrun bugs in their strxfrm() implementations. The bugs were fixed more than a decade ago and the relevant releases are long out of vendor support. It's time to remove the defense added by commit be8b06c. Reviewed-by: Nathan Bossart <nathandbossart@gmail.com> Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us> Discussion: https://postgr.es/m/CA+hUKGJ-ZPJwKHVLbqye92-ZXeLoCHu5wJL6L6HhNP7FkJ=meA@mail.gmail.com
1 parent 4b5fb33 commit e790528

File tree

4 files changed

+0
-63
lines changed

4 files changed

+0
-63
lines changed

src/backend/main/main.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,8 +137,6 @@ main(int argc, char *argv[])
137137
*/
138138
unsetenv("LC_ALL");
139139

140-
check_strxfrm_bug();
141-
142140
/*
143141
* Catch standard options before doing much else, in particular before we
144142
* insist on not being root.

src/backend/utils/adt/pg_locale.c

Lines changed: 0 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -1162,64 +1162,6 @@ IsoLocaleName(const char *winlocname)
11621162
#endif /* WIN32 && LC_MESSAGES */
11631163

11641164

1165-
/*
1166-
* Detect aging strxfrm() implementations that, in a subset of locales, write
1167-
* past the specified buffer length. Affected users must update OS packages
1168-
* before using PostgreSQL 9.5 or later.
1169-
*
1170-
* Assume that the bug can come and go from one postmaster startup to another
1171-
* due to physical replication among diverse machines. Assume that the bug's
1172-
* presence will not change during the life of a particular postmaster. Given
1173-
* those assumptions, call this no less than once per postmaster startup per
1174-
* LC_COLLATE setting used. No known-affected system offers strxfrm_l(), so
1175-
* there is no need to consider pg_collation locales.
1176-
*/
1177-
void
1178-
check_strxfrm_bug(void)
1179-
{
1180-
char buf[32];
1181-
const int canary = 0x7F;
1182-
bool ok = true;
1183-
1184-
/*
1185-
* Given a two-byte ASCII string and length limit 7, 8 or 9, Solaris 10
1186-
* 05/08 returns 18 and modifies 10 bytes. It respects limits above or
1187-
* below that range.
1188-
*
1189-
* The bug is present in Solaris 8 as well; it is absent in Solaris 10
1190-
* 01/13 and Solaris 11.2. Affected locales include is_IS.ISO8859-1,
1191-
* en_US.UTF-8, en_US.ISO8859-1, and ru_RU.KOI8-R. Unaffected locales
1192-
* include de_DE.UTF-8, de_DE.ISO8859-1, zh_TW.UTF-8, and C.
1193-
*/
1194-
buf[7] = canary;
1195-
(void) strxfrm(buf, "ab", 7);
1196-
if (buf[7] != canary)
1197-
ok = false;
1198-
1199-
/*
1200-
* illumos bug #1594 was present in the source tree from 2010-10-11 to
1201-
* 2012-02-01. Given an ASCII string of any length and length limit 1,
1202-
* affected systems ignore the length limit and modify a number of bytes
1203-
* one less than the return value. The problem inputs for this bug do not
1204-
* overlap those for the Solaris bug, hence a distinct test.
1205-
*
1206-
* Affected systems include smartos-20110926T021612Z. Affected locales
1207-
* include en_US.ISO8859-1 and en_US.UTF-8. Unaffected locales include C.
1208-
*/
1209-
buf[1] = canary;
1210-
(void) strxfrm(buf, "a", 1);
1211-
if (buf[1] != canary)
1212-
ok = false;
1213-
1214-
if (!ok)
1215-
ereport(ERROR,
1216-
(errcode(ERRCODE_SYSTEM_ERROR),
1217-
errmsg_internal("strxfrm(), in locale \"%s\", writes past the specified array length",
1218-
setlocale(LC_COLLATE, NULL)),
1219-
errhint("Apply system library package updates.")));
1220-
}
1221-
1222-
12231165
/*
12241166
* Cache mechanism for collation information.
12251167
*

src/backend/utils/init/postinit.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -487,8 +487,6 @@ CheckMyDatabase(const char *name, bool am_superuser, bool override_allow_connect
487487
SetConfigOption("lc_collate", collate, PGC_INTERNAL, PGC_S_DYNAMIC_DEFAULT);
488488
SetConfigOption("lc_ctype", ctype, PGC_INTERNAL, PGC_S_DYNAMIC_DEFAULT);
489489

490-
check_strxfrm_bug();
491-
492490
ReleaseSysCache(tup);
493491
}
494492

src/include/utils/pg_locale.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@ extern PGDLLIMPORT bool database_ctype_is_c;
5353

5454
extern bool check_locale(int category, const char *locale, char **canonname);
5555
extern char *pg_perm_setlocale(int category, const char *locale);
56-
extern void check_strxfrm_bug(void);
5756

5857
extern bool lc_collate_is_c(Oid collation);
5958
extern bool lc_ctype_is_c(Oid collation);

0 commit comments

Comments
 (0)