summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBruce Momjian1999-07-20 17:20:43 +0000
committerBruce Momjian1999-07-20 17:20:43 +0000
commitf96babac12cdf5cef5f18686916a95e089fa1203 (patch)
tree94ad24e011d85bb6f733e39b79de10cab656bdec
parenta2bb39c7381a4cf2050fe612c8a59b3ffaa71dd7 (diff)
While I was running some tests in psql, trying to figure out how to change
the query string to handle any length, I discovered that under certain conditions, psql will core dump when handling long strings. Thus, the patch. It was caused by a buffer overrun, probably not noticeable in a lot of cases, but pretty noticeable in mine. Problem was caused by the fact that the length check is only performed after the check for a ; to get the end of the query and execute. Cheers... MikeA
-rw-r--r--src/bin/psql/psql.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/bin/psql/psql.c b/src/bin/psql/psql.c
index d3b93f32d85..20f4adb05fc 100644
--- a/src/bin/psql/psql.c
+++ b/src/bin/psql/psql.c
@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/bin/psql/Attic/psql.c,v 1.187 1999/07/19 21:06:19 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/bin/psql/Attic/psql.c,v 1.188 1999/07/20 17:20:43 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -2705,7 +2705,8 @@ MainLoop(PsqlSettings *pset, char *query, FILE *source)
char hold_char = line[i + thislen];
line[i + thislen] = '\0';
- if (query_start[0] != '\0')
+ if ((query_start[0] != '\0') &&
+ (strlen(query) + strlen(query_start) <= MAX_QUERY_BUFFER))
{
if (query[0] != '\0')
{