pg.ddx.io pgsql-committers@postgresql.org mailing list archivehelp / color / mirror / Atom feed
pgsql: Make pg_regexec() robust against out-of-range search_start. 7+ messages / 1 participants [nested] [flat]
* pgsql: Make pg_regexec() robust against out-of-range search_start. @ 2021-09-11 19:21 Tom Lane <tgl@sss.pgh.pa.us> 0 siblings, 0 replies; 7+ messages in thread From: Tom Lane @ 2021-09-11 19:21 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org Make pg_regexec() robust against out-of-range search_start. If search_start is greater than the length of the string, we should just return REG_NOMATCH immediately. (Note that the equality case should *not* be rejected, since the pattern might be able to match zero characters.) This guards various internal assumptions that the min of a range of string positions is not more than the max. Violation of those assumptions could allow an attempt to fetch string[search_start-1], possibly causing a crash. Jaime Casanova pointed out that this situation is reachable with the new regexp_xxx functions that accept a user-specified start position. I don't believe it's reachable via any in-core call site in v14 and below. However, extensions could possibly call pg_regexec with an out-of-range search_start, so let's back-patch the fix anyway. Discussion: https://postgr.es/m/20210911180357.GA6870@ahch-to Branch ------ master Details ------- https://git.postgresql.org/pg/commitdiff/e757080e041214cf6983e3e77ef01e83f1371d72 Modified Files -------------- src/backend/regex/regexec.c | 2 ++ 1 file changed, 2 insertions(+) ^ permalink raw reply [nested|flat] 7+ messages in thread
* pgsql: Make pg_regexec() robust against out-of-range search_start. @ 2021-09-11 19:21 Tom Lane <tgl@sss.pgh.pa.us> 0 siblings, 0 replies; 7+ messages in thread From: Tom Lane @ 2021-09-11 19:21 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org Make pg_regexec() robust against out-of-range search_start. If search_start is greater than the length of the string, we should just return REG_NOMATCH immediately. (Note that the equality case should *not* be rejected, since the pattern might be able to match zero characters.) This guards various internal assumptions that the min of a range of string positions is not more than the max. Violation of those assumptions could allow an attempt to fetch string[search_start-1], possibly causing a crash. Jaime Casanova pointed out that this situation is reachable with the new regexp_xxx functions that accept a user-specified start position. I don't believe it's reachable via any in-core call site in v14 and below. However, extensions could possibly call pg_regexec with an out-of-range search_start, so let's back-patch the fix anyway. Discussion: https://postgr.es/m/20210911180357.GA6870@ahch-to Branch ------ REL_14_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/b33283cbd336adbf982c21aac1399130c8ffaaa9 Modified Files -------------- src/backend/regex/regexec.c | 2 ++ 1 file changed, 2 insertions(+) ^ permalink raw reply [nested|flat] 7+ messages in thread
* pgsql: Make pg_regexec() robust against out-of-range search_start. @ 2021-09-11 19:21 Tom Lane <tgl@sss.pgh.pa.us> 0 siblings, 0 replies; 7+ messages in thread From: Tom Lane @ 2021-09-11 19:21 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org Make pg_regexec() robust against out-of-range search_start. If search_start is greater than the length of the string, we should just return REG_NOMATCH immediately. (Note that the equality case should *not* be rejected, since the pattern might be able to match zero characters.) This guards various internal assumptions that the min of a range of string positions is not more than the max. Violation of those assumptions could allow an attempt to fetch string[search_start-1], possibly causing a crash. Jaime Casanova pointed out that this situation is reachable with the new regexp_xxx functions that accept a user-specified start position. I don't believe it's reachable via any in-core call site in v14 and below. However, extensions could possibly call pg_regexec with an out-of-range search_start, so let's back-patch the fix anyway. Discussion: https://postgr.es/m/20210911180357.GA6870@ahch-to Branch ------ REL_13_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/7e420072ea4a9f873d3378c8b35f2d939d925022 Modified Files -------------- src/backend/regex/regexec.c | 2 ++ 1 file changed, 2 insertions(+) ^ permalink raw reply [nested|flat] 7+ messages in thread
* pgsql: Make pg_regexec() robust against out-of-range search_start. @ 2021-09-11 19:21 Tom Lane <tgl@sss.pgh.pa.us> 0 siblings, 0 replies; 7+ messages in thread From: Tom Lane @ 2021-09-11 19:21 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org Make pg_regexec() robust against out-of-range search_start. If search_start is greater than the length of the string, we should just return REG_NOMATCH immediately. (Note that the equality case should *not* be rejected, since the pattern might be able to match zero characters.) This guards various internal assumptions that the min of a range of string positions is not more than the max. Violation of those assumptions could allow an attempt to fetch string[search_start-1], possibly causing a crash. Jaime Casanova pointed out that this situation is reachable with the new regexp_xxx functions that accept a user-specified start position. I don't believe it's reachable via any in-core call site in v14 and below. However, extensions could possibly call pg_regexec with an out-of-range search_start, so let's back-patch the fix anyway. Discussion: https://postgr.es/m/20210911180357.GA6870@ahch-to Branch ------ REL_12_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/3adde7eb6633bea734c4513ebd96adca78b7737c Modified Files -------------- src/backend/regex/regexec.c | 2 ++ 1 file changed, 2 insertions(+) ^ permalink raw reply [nested|flat] 7+ messages in thread
* pgsql: Make pg_regexec() robust against out-of-range search_start. @ 2021-09-11 19:21 Tom Lane <tgl@sss.pgh.pa.us> 0 siblings, 0 replies; 7+ messages in thread From: Tom Lane @ 2021-09-11 19:21 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org Make pg_regexec() robust against out-of-range search_start. If search_start is greater than the length of the string, we should just return REG_NOMATCH immediately. (Note that the equality case should *not* be rejected, since the pattern might be able to match zero characters.) This guards various internal assumptions that the min of a range of string positions is not more than the max. Violation of those assumptions could allow an attempt to fetch string[search_start-1], possibly causing a crash. Jaime Casanova pointed out that this situation is reachable with the new regexp_xxx functions that accept a user-specified start position. I don't believe it's reachable via any in-core call site in v14 and below. However, extensions could possibly call pg_regexec with an out-of-range search_start, so let's back-patch the fix anyway. Discussion: https://postgr.es/m/20210911180357.GA6870@ahch-to Branch ------ REL_11_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/3be381a900df75de6a085cc3a465d85ec8bf39cd Modified Files -------------- src/backend/regex/regexec.c | 2 ++ 1 file changed, 2 insertions(+) ^ permalink raw reply [nested|flat] 7+ messages in thread
* pgsql: Make pg_regexec() robust against out-of-range search_start. @ 2021-09-11 19:21 Tom Lane <tgl@sss.pgh.pa.us> 0 siblings, 0 replies; 7+ messages in thread From: Tom Lane @ 2021-09-11 19:21 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org Make pg_regexec() robust against out-of-range search_start. If search_start is greater than the length of the string, we should just return REG_NOMATCH immediately. (Note that the equality case should *not* be rejected, since the pattern might be able to match zero characters.) This guards various internal assumptions that the min of a range of string positions is not more than the max. Violation of those assumptions could allow an attempt to fetch string[search_start-1], possibly causing a crash. Jaime Casanova pointed out that this situation is reachable with the new regexp_xxx functions that accept a user-specified start position. I don't believe it's reachable via any in-core call site in v14 and below. However, extensions could possibly call pg_regexec with an out-of-range search_start, so let's back-patch the fix anyway. Discussion: https://postgr.es/m/20210911180357.GA6870@ahch-to Branch ------ REL_10_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/daac97eb0b9f680916561ae636ce554fbeec8bd5 Modified Files -------------- src/backend/regex/regexec.c | 2 ++ 1 file changed, 2 insertions(+) ^ permalink raw reply [nested|flat] 7+ messages in thread
* pgsql: Make pg_regexec() robust against out-of-range search_start. @ 2021-09-11 19:21 Tom Lane <tgl@sss.pgh.pa.us> 0 siblings, 0 replies; 7+ messages in thread From: Tom Lane @ 2021-09-11 19:21 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org Make pg_regexec() robust against out-of-range search_start. If search_start is greater than the length of the string, we should just return REG_NOMATCH immediately. (Note that the equality case should *not* be rejected, since the pattern might be able to match zero characters.) This guards various internal assumptions that the min of a range of string positions is not more than the max. Violation of those assumptions could allow an attempt to fetch string[search_start-1], possibly causing a crash. Jaime Casanova pointed out that this situation is reachable with the new regexp_xxx functions that accept a user-specified start position. I don't believe it's reachable via any in-core call site in v14 and below. However, extensions could possibly call pg_regexec with an out-of-range search_start, so let's back-patch the fix anyway. Discussion: https://postgr.es/m/20210911180357.GA6870@ahch-to Branch ------ REL9_6_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/ec89d7acedcd84d51d4868f9763183fe9005f46b Modified Files -------------- src/backend/regex/regexec.c | 2 ++ 1 file changed, 2 insertions(+) ^ permalink raw reply [nested|flat] 7+ messages in thread
end of thread, other threads:[~2021-09-11 19:21 UTC | newest] Thread overview: 7+ messages (download: mbox mbox.gz follow: Atom feed) -- links below jump to the message on this page -- 2021-09-11 19:21 pgsql: Make pg_regexec() robust against out-of-range search_start. Tom Lane <tgl@sss.pgh.pa.us> 2021-09-11 19:21 pgsql: Make pg_regexec() robust against out-of-range search_start. Tom Lane <tgl@sss.pgh.pa.us> 2021-09-11 19:21 pgsql: Make pg_regexec() robust against out-of-range search_start. Tom Lane <tgl@sss.pgh.pa.us> 2021-09-11 19:21 pgsql: Make pg_regexec() robust against out-of-range search_start. Tom Lane <tgl@sss.pgh.pa.us> 2021-09-11 19:21 pgsql: Make pg_regexec() robust against out-of-range search_start. Tom Lane <tgl@sss.pgh.pa.us> 2021-09-11 19:21 pgsql: Make pg_regexec() robust against out-of-range search_start. Tom Lane <tgl@sss.pgh.pa.us> 2021-09-11 19:21 pgsql: Make pg_regexec() robust against out-of-range search_start. Tom Lane <tgl@sss.pgh.pa.us>
This inbox is served by DDX for PostgreSQL; see mirroring instructions for how to clone and mirror all data and code used for this inbox