pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
pgsql: pgbench: avoid FD_ISSET on an invalid file descriptor
6+ messages / 1 participants
[nested] [flat]

* pgsql: pgbench: avoid FD_ISSET on an invalid file descriptor
@ 2016-02-15 23:37 Alvaro Herrera <alvherre@alvh.no-ip.org>
  0 siblings, 0 replies; 6+ messages in thread

From: Alvaro Herrera @ 2016-02-15 23:37 UTC (permalink / raw)
  To: pgsql-committers

pgbench: avoid FD_ISSET on an invalid file descriptor

The original code wasn't careful to test the file descriptor returned by
PQsocket() for an invalid socket.  If an invalid socket did turn up,
that would amount to calling FD_ISSET with fd = -1, whereby undefined
behavior can be invoked.

To fix, test file descriptor for validity and stop further processing if
that fails.

Problem noticed by Coverity.

There is an existing FD_ISSET callsite that does check for invalid
sockets beforehand, but the error message reported by it was
strerror(errno); in testing the aforementioned change, that turns out to
result in "bad socket: Success" which isn't terribly helpful.  Instead
use PQerrorMessage() in both places which is more likely to contain an
useful error message.

Backpatch-through: 9.1.

Branch
------
master

Details
-------
http://git.postgresql.org/pg/commitdiff/5df44d14ba9fd3f6149c3fa0919745c9e24bcffe

Modified Files
--------------
src/bin/pgbench/pgbench.c | 20 +++++++++++++++-----
1 file changed, 15 insertions(+), 5 deletions(-)


-- 
Sent via pgsql-committers mailing list (pgsql-committers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-committers


^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* pgsql: pgbench: avoid FD_ISSET on an invalid file descriptor
@ 2016-02-15 23:37 Alvaro Herrera <alvherre@alvh.no-ip.org>
  0 siblings, 0 replies; 6+ messages in thread

From: Alvaro Herrera @ 2016-02-15 23:37 UTC (permalink / raw)
  To: pgsql-committers

pgbench: avoid FD_ISSET on an invalid file descriptor

The original code wasn't careful to test the file descriptor returned by
PQsocket() for an invalid socket.  If an invalid socket did turn up,
that would amount to calling FD_ISSET with fd = -1, whereby undefined
behavior can be invoked.

To fix, test file descriptor for validity and stop further processing if
that fails.

Problem noticed by Coverity.

There is an existing FD_ISSET callsite that does check for invalid
sockets beforehand, but the error message reported by it was
strerror(errno); in testing the aforementioned change, that turns out to
result in "bad socket: Success" which isn't terribly helpful.  Instead
use PQerrorMessage() in both places which is more likely to contain an
useful error message.

Backpatch-through: 9.1.

Branch
------
REL9_5_STABLE

Details
-------
http://git.postgresql.org/pg/commitdiff/1bad289a8085aa5e550f70c50b3e63362ddbd31f

Modified Files
--------------
src/bin/pgbench/pgbench.c | 20 +++++++++++++++-----
1 file changed, 15 insertions(+), 5 deletions(-)


-- 
Sent via pgsql-committers mailing list (pgsql-committers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-committers


^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* pgsql: pgbench: avoid FD_ISSET on an invalid file descriptor
@ 2016-02-15 23:37 Alvaro Herrera <alvherre@alvh.no-ip.org>
  0 siblings, 0 replies; 6+ messages in thread

From: Alvaro Herrera @ 2016-02-15 23:37 UTC (permalink / raw)
  To: pgsql-committers

pgbench: avoid FD_ISSET on an invalid file descriptor

The original code wasn't careful to test the file descriptor returned by
PQsocket() for an invalid socket.  If an invalid socket did turn up,
that would amount to calling FD_ISSET with fd = -1, whereby undefined
behavior can be invoked.

To fix, test file descriptor for validity and stop further processing if
that fails.

Problem noticed by Coverity.

There is an existing FD_ISSET callsite that does check for invalid
sockets beforehand, but the error message reported by it was
strerror(errno); in testing the aforementioned change, that turns out to
result in "bad socket: Success" which isn't terribly helpful.  Instead
use PQerrorMessage() in both places which is more likely to contain an
useful error message.

Backpatch-through: 9.1.

Branch
------
REL9_4_STABLE

Details
-------
http://git.postgresql.org/pg/commitdiff/ccbb01ff4a4cac8622930ef6475ed3cf8281e4c7

Modified Files
--------------
contrib/pgbench/pgbench.c | 20 +++++++++++++++-----
1 file changed, 15 insertions(+), 5 deletions(-)


-- 
Sent via pgsql-committers mailing list (pgsql-committers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-committers


^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* pgsql: pgbench: avoid FD_ISSET on an invalid file descriptor
@ 2016-02-15 23:37 Alvaro Herrera <alvherre@alvh.no-ip.org>
  0 siblings, 0 replies; 6+ messages in thread

From: Alvaro Herrera @ 2016-02-15 23:37 UTC (permalink / raw)
  To: pgsql-committers

pgbench: avoid FD_ISSET on an invalid file descriptor

The original code wasn't careful to test the file descriptor returned by
PQsocket() for an invalid socket.  If an invalid socket did turn up,
that would amount to calling FD_ISSET with fd = -1, whereby undefined
behavior can be invoked.

To fix, test file descriptor for validity and stop further processing if
that fails.

Problem noticed by Coverity.

There is an existing FD_ISSET callsite that does check for invalid
sockets beforehand, but the error message reported by it was
strerror(errno); in testing the aforementioned change, that turns out to
result in "bad socket: Success" which isn't terribly helpful.  Instead
use PQerrorMessage() in both places which is more likely to contain an
useful error message.

Backpatch-through: 9.1.

Branch
------
REL9_3_STABLE

Details
-------
http://git.postgresql.org/pg/commitdiff/baa7f635367e0e66f8bdb1998fb99d6f47203b1c

Modified Files
--------------
contrib/pgbench/pgbench.c | 20 +++++++++++++++-----
1 file changed, 15 insertions(+), 5 deletions(-)


-- 
Sent via pgsql-committers mailing list (pgsql-committers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-committers


^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* pgsql: pgbench: avoid FD_ISSET on an invalid file descriptor
@ 2016-02-15 23:37 Alvaro Herrera <alvherre@alvh.no-ip.org>
  0 siblings, 0 replies; 6+ messages in thread

From: Alvaro Herrera @ 2016-02-15 23:37 UTC (permalink / raw)
  To: pgsql-committers

pgbench: avoid FD_ISSET on an invalid file descriptor

The original code wasn't careful to test the file descriptor returned by
PQsocket() for an invalid socket.  If an invalid socket did turn up,
that would amount to calling FD_ISSET with fd = -1, whereby undefined
behavior can be invoked.

To fix, test file descriptor for validity and stop further processing if
that fails.

Problem noticed by Coverity.

There is an existing FD_ISSET callsite that does check for invalid
sockets beforehand, but the error message reported by it was
strerror(errno); in testing the aforementioned change, that turns out to
result in "bad socket: Success" which isn't terribly helpful.  Instead
use PQerrorMessage() in both places which is more likely to contain an
useful error message.

Backpatch-through: 9.1.

Branch
------
REL9_2_STABLE

Details
-------
http://git.postgresql.org/pg/commitdiff/daac53779acdab512e8347ce7472cf0923cd8598

Modified Files
--------------
contrib/pgbench/pgbench.c | 20 +++++++++++++++-----
1 file changed, 15 insertions(+), 5 deletions(-)


-- 
Sent via pgsql-committers mailing list (pgsql-committers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-committers


^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* pgsql: pgbench: avoid FD_ISSET on an invalid file descriptor
@ 2016-02-15 23:37 Alvaro Herrera <alvherre@alvh.no-ip.org>
  0 siblings, 0 replies; 6+ messages in thread

From: Alvaro Herrera @ 2016-02-15 23:37 UTC (permalink / raw)
  To: pgsql-committers

pgbench: avoid FD_ISSET on an invalid file descriptor

The original code wasn't careful to test the file descriptor returned by
PQsocket() for an invalid socket.  If an invalid socket did turn up,
that would amount to calling FD_ISSET with fd = -1, whereby undefined
behavior can be invoked.

To fix, test file descriptor for validity and stop further processing if
that fails.

Problem noticed by Coverity.

There is an existing FD_ISSET callsite that does check for invalid
sockets beforehand, but the error message reported by it was
strerror(errno); in testing the aforementioned change, that turns out to
result in "bad socket: Success" which isn't terribly helpful.  Instead
use PQerrorMessage() in both places which is more likely to contain an
useful error message.

Backpatch-through: 9.1.

Branch
------
REL9_1_STABLE

Details
-------
http://git.postgresql.org/pg/commitdiff/0b2aefe74afaf418ca74f31fc3ef39f2a3cd336a

Modified Files
--------------
contrib/pgbench/pgbench.c | 20 +++++++++++++++-----
1 file changed, 15 insertions(+), 5 deletions(-)


-- 
Sent via pgsql-committers mailing list (pgsql-committers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-committers


^ permalink  raw  reply  [nested|flat] 6+ messages in thread


end of thread, other threads:[~2016-02-15 23:37 UTC | newest]

Thread overview: 6+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2016-02-15 23:37 pgsql: pgbench: avoid FD_ISSET on an invalid file descriptor Alvaro Herrera <alvherre@alvh.no-ip.org>
2016-02-15 23:37 pgsql: pgbench: avoid FD_ISSET on an invalid file descriptor Alvaro Herrera <alvherre@alvh.no-ip.org>
2016-02-15 23:37 pgsql: pgbench: avoid FD_ISSET on an invalid file descriptor Alvaro Herrera <alvherre@alvh.no-ip.org>
2016-02-15 23:37 pgsql: pgbench: avoid FD_ISSET on an invalid file descriptor Alvaro Herrera <alvherre@alvh.no-ip.org>
2016-02-15 23:37 pgsql: pgbench: avoid FD_ISSET on an invalid file descriptor Alvaro Herrera <alvherre@alvh.no-ip.org>
2016-02-15 23:37 pgsql: pgbench: avoid FD_ISSET on an invalid file descriptor Alvaro Herrera <alvherre@alvh.no-ip.org>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox