summaryrefslogtreecommitdiff
path: root/src/include/miscadmin.h
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2015-10-02 14:51:58 -0400
committerTom Lane <tgl@sss.pgh.pa.us>2015-10-02 14:51:58 -0400
commitc5e38b93c62fa360bb054c41a864ab45d9eccea0 (patch)
tree2fa7e5e1444d3ee9af510a1fc366d8dadac34a63 /src/include/miscadmin.h
parentc0215b2cf651f06d3040daaf2c0b9836950413e3 (diff)
Add recursion depth protections to regular expression matching.
Some of the functions in regex compilation and execution recurse, and therefore could in principle be driven to stack overflow. The Tcl crew has seen this happen in practice in duptraverse(), though their fix was to put in a hard-wired limit on the number of recursive levels, which is not too appetizing --- fortunately, we have enough infrastructure to check the actually available stack. Greg Stark has also seen it in other places while fuzz testing on a machine with limited stack space. Let's put guards in to prevent crashes in all these places. Since the regex code would leak memory if we simply threw elog(ERROR), we have to introduce an API that checks for stack depth without throwing such an error. Fortunately that's not difficult.
Diffstat (limited to 'src/include/miscadmin.h')
-rw-r--r--src/include/miscadmin.h1
1 files changed, 1 insertions, 0 deletions
diff --git a/src/include/miscadmin.h b/src/include/miscadmin.h
index d3b5022a841..ca23f083331 100644
--- a/src/include/miscadmin.h
+++ b/src/include/miscadmin.h
@@ -268,6 +268,7 @@ typedef char *pg_stack_base_t;
extern pg_stack_base_t set_stack_base(void);
extern void restore_stack_base(pg_stack_base_t base);
extern void check_stack_depth(void);
+extern bool stack_is_too_deep(void);
/* in tcop/utility.c */
extern void PreventCommandIfReadOnly(const char *cmdname);