mirror of
https://github.com/postgres/postgres.git
synced 2025-06-27 23:21:58 +03:00
Adjust the behavior of the PQExpBuffer code to make it have well-defined
results (ie, an empty "broken" buffer) if memory overrun occurs anywhere along the way to filling the buffer. The previous coding would just silently discard portions of the intended buffer contents, as exhibited in trouble report from Sam Mason. Also, tweak psql's main loop to correctly detect and report such overruns. There's probably much more that should be done in this line, but this is a start.
This commit is contained in:
@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/interfaces/libpq/fe-connect.c,v 1.369 2008/11/25 19:30:42 tgl Exp $
|
||||
* $PostgreSQL: pgsql/src/interfaces/libpq/fe-connect.c,v 1.370 2008/11/26 00:26:23 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -585,7 +585,7 @@ PQconndefaults(void)
|
||||
PQconninfoOption *connOptions;
|
||||
|
||||
initPQExpBuffer(&errorBuf);
|
||||
if (errorBuf.data == NULL)
|
||||
if (PQExpBufferBroken(&errorBuf))
|
||||
return NULL; /* out of memory already :-( */
|
||||
connOptions = conninfo_parse("", &errorBuf, true);
|
||||
termPQExpBuffer(&errorBuf);
|
||||
@ -1970,8 +1970,8 @@ makeEmptyPGconn(void)
|
||||
|
||||
if (conn->inBuffer == NULL ||
|
||||
conn->outBuffer == NULL ||
|
||||
conn->errorMessage.data == NULL ||
|
||||
conn->workBuffer.data == NULL)
|
||||
PQExpBufferBroken(&conn->errorMessage) ||
|
||||
PQExpBufferBroken(&conn->workBuffer))
|
||||
{
|
||||
/* out of memory already :-( */
|
||||
freePGconn(conn);
|
||||
@ -3151,7 +3151,7 @@ PQconninfoParse(const char *conninfo, char **errmsg)
|
||||
if (errmsg)
|
||||
*errmsg = NULL; /* default */
|
||||
initPQExpBuffer(&errorBuf);
|
||||
if (errorBuf.data == NULL)
|
||||
if (PQExpBufferBroken(&errorBuf))
|
||||
return NULL; /* out of memory already :-( */
|
||||
connOptions = conninfo_parse(conninfo, &errorBuf, false);
|
||||
if (connOptions == NULL && errmsg)
|
||||
|
Reference in New Issue
Block a user