pgsql: Tweak libpq to avoid crashing due to incorrect buffer size - Mailing list pgsql-committers

From tgl@postgresql.org (Tom Lane)
Subject pgsql: Tweak libpq to avoid crashing due to incorrect buffer size
Date
Msg-id 20080529220244.ABB9E754C54@cvs.postgresql.org
Whole thread Raw
List pgsql-committers
Log Message:
-----------
Tweak libpq to avoid crashing due to incorrect buffer size calculation when
we are on a 64-bit machine (ie, size_t is wider than int) and someone passes
in a query string that approaches or exceeds INT_MAX bytes.  Also, just for
paranoia's sake, guard against similar overflows in sizing the input buffer.

The backend will not in the foreseeable future be prepared to send or receive
strings exceeding 1GB, so I didn't take the more invasive step of switching
all the buffer index variables from int to size_t; though someday we might
want to do that.

I have a suspicion that this is not the only such bug in libpq, but this
fix is enough to take care of the crash reported by Francisco Reyes.

Modified Files:
--------------
    pgsql/src/interfaces/libpq:
        fe-connect.c (r1.358 -> r1.359)
        (http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/src/interfaces/libpq/fe-connect.c?r1=1.358&r2=1.359)
        fe-exec.c (r1.194 -> r1.195)
        (http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/src/interfaces/libpq/fe-exec.c?r1=1.194&r2=1.195)
        fe-misc.c (r1.133 -> r1.134)
        (http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/src/interfaces/libpq/fe-misc.c?r1=1.133&r2=1.134)
        fe-protocol3.c (r1.34 -> r1.35)
        (http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/src/interfaces/libpq/fe-protocol3.c?r1=1.34&r2=1.35)
        libpq-int.h (r1.130 -> r1.131)
        (http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/src/interfaces/libpq/libpq-int.h?r1=1.130&r2=1.131)

pgsql-committers by date:

Previous
From: gleu@pgfoundry.org (User Gleu)
Date:
Subject: pgsnap - pgsnap: TODO review.
Next
From: tgl@postgresql.org (Tom Lane)
Date:
Subject: pgsql: Improve the documentation comment for replace().