diff options
Diffstat (limited to 'src/backend/tcop/postgres.c')
-rw-r--r-- | src/backend/tcop/postgres.c | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/src/backend/tcop/postgres.c b/src/backend/tcop/postgres.c index edf18fd0f20..60f3c7c63d0 100644 --- a/src/backend/tcop/postgres.c +++ b/src/backend/tcop/postgres.c @@ -19,10 +19,11 @@ #include "postgres.h" +#include <fcntl.h> +#include <limits.h> +#include <signal.h> #include <time.h> #include <unistd.h> -#include <signal.h> -#include <fcntl.h> #include <sys/socket.h> #ifdef HAVE_SYS_SELECT_H #include <sys/select.h> @@ -4107,7 +4108,7 @@ PostgresMain(int argc, char *argv[], const char *username) /* * Obtain platform stack depth limit (in bytes) * - * Return -1 if unlimited or not known + * Return -1 if unknown */ long get_stack_depth_rlimit(void) @@ -4123,7 +4124,10 @@ get_stack_depth_rlimit(void) if (getrlimit(RLIMIT_STACK, &rlim) < 0) val = -1; else if (rlim.rlim_cur == RLIM_INFINITY) - val = -1; + val = LONG_MAX; + /* rlim_cur is probably of an unsigned type, so check for overflow */ + else if (rlim.rlim_cur >= LONG_MAX) + val = LONG_MAX; else val = rlim.rlim_cur; } |