mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-01-15 15:41:24 +01:00
fix buffer overflow sql error with large messages; combine logged messages.
This commit is contained in:
parent
8bf8383d60
commit
633d4c95a7
1 changed files with 4 additions and 4 deletions
|
@ -306,8 +306,7 @@ DBMgr::execSql( const char* query )
|
|||
{
|
||||
PGresult* result = PQexec( getThreadConn(), query );
|
||||
if ( PGRES_COMMAND_OK != PQresultStatus(result) ) {
|
||||
logf( XW_LOGERROR, "PQexec=>%s", PQresStatus(PQresultStatus(result) ));
|
||||
logf( XW_LOGERROR, "PQexec=>%s", PQresultErrorMessage(result) );
|
||||
logf( XW_LOGERROR, "PQexec=>%s;%s", PQresStatus(PQresultStatus(result)), PQresultErrorMessage(result) );
|
||||
}
|
||||
PQclear( result );
|
||||
}
|
||||
|
@ -388,10 +387,11 @@ DBMgr::StoreMessage( const char* const connName, int hid,
|
|||
unsigned char* bytes = PQescapeByteaConn( getThreadConn(), buf, len, &newLen );
|
||||
assert( NULL != bytes );
|
||||
|
||||
char query[512];
|
||||
snprintf( query, sizeof(query), fmt, connName, hid, bytes );
|
||||
char query[newLen+128];
|
||||
unsigned int siz = snprintf( query, sizeof(query), fmt, connName, hid, bytes );
|
||||
logf( XW_LOGINFO, "%s: query: %s", __func__, query );
|
||||
PQfreemem( bytes );
|
||||
assert( siz < sizeof(query) );
|
||||
|
||||
execSql( query );
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue