Bug #924: Segmentation fault in libpq/PQconsumeInput on SSL connection

From: pgsql-bugs(at)postgresql(dot)org
To: pgsql-bugs(at)postgresql(dot)org
Subject: Bug #924: Segmentation fault in libpq/PQconsumeInput on SSL connection
Date: 2003-03-29 02:02:56
Message-ID: 20030329020256.8BDB847580B@postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

Sergey N. Yatskevich (syatskevich(at)n21lab(dot)gosniias(dot)msk(dot)ru) reports a bug with a severity of 3
The lower the number the more severe it is.

Short Description
Segmentation fault in libpq/PQconsumeInput on SSL connection

Long Description
When I start SSL connection and try to handle async query:

// run query action handler
void
SqlDialog::sendQuery (const QString &_query) {
PQsendQuery (m_conn, _query.utf8 ());
connect(m_idle_timer, SIGNAL(timeout()), this, processQuery())
}

// run in idle loop
void
SqlDialog::processQuery () {
// load data from server
PQconsumeInput (conn);

// if data not ready yet - return
if (PQisBusy (conn))
return;

// process next query result when data completly loaded
PQresult *res = PQgetResult (conn);
if (res) {
...

// wait next result
return;
}

// all results handled
disconnect(m_idle_timer, SIGNAL(timeout()), this, processQuery());
}

I get segmentation fault in PQconsumeInput. I run gdb
and found that pqsecure_read recursive call itself infinite on
SSL_ERROR_WANT_READ return code from libssl. I don't know why but
this code don't work well for me and cause Stack Overflow
(reported by OS (ALTLinux) as Segmentation Fault) error.

I solve this problem easy: instead recirsive call pqsecure_read
on SSL_ERROR_WANT_READ I simple return 0 as count of readed bytes.
n = pqsecure_read (...)
replace with
n = 0;
in pqsecure_read. I do that in pqsecure_write on SSL_ERROR_WANT_WRITE
also.

I check all places where pqsecure_* called and found that 0
handled currectly at all.

OS: ALTLinux - Sisyphus
Kernel: Linux-2.4.20
PostgreSQL: 7.3.2
Qt: 3.0.5, 3.1.2
libssl: 0.9.6i

Sample Code

No file was uploaded with this report

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message pgsql-bugs 2003-03-29 02:09:07 Bug #925: typing error in src/backend/libpq/be-secure.c ???
Previous Message pgsql-bugs 2003-03-28 22:36:49 Bug #923: psql can't read file prepaired by pg_dumpall