Skip to content

Commit f96baba

Browse files
committed
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
1 parent a2bb39c commit f96baba

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/bin/psql/psql.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
*
99
* IDENTIFICATION
10-
* $Header: /cvsroot/pgsql/src/bin/psql/Attic/psql.c,v 1.187 1999/07/19 21:06:19 momjian Exp $
10+
* $Header: /cvsroot/pgsql/src/bin/psql/Attic/psql.c,v 1.188 1999/07/20 17:20:43 momjian Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -2705,7 +2705,8 @@ MainLoop(PsqlSettings *pset, char *query, FILE *source)
27052705
char hold_char = line[i + thislen];
27062706

27072707
line[i + thislen] = '\0';
2708-
if (query_start[0] != '\0')
2708+
if ((query_start[0] != '\0') &&
2709+
(strlen(query) + strlen(query_start) <= MAX_QUERY_BUFFER))
27092710
{
27102711
if (query[0] != '\0')
27112712
{

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy