aboutsummaryrefslogtreecommitdiff
path: root/src/backend/access/transam/xlog.c
diff options
context:
space:
mode:
authorAlvaro Herrera <alvherre@alvh.no-ip.org>2016-02-15 20:33:43 -0300
committerAlvaro Herrera <alvherre@alvh.no-ip.org>2016-02-15 20:33:43 -0300
commit5df44d14ba9fd3f6149c3fa0919745c9e24bcffe (patch)
tree0b9d5307df244568ed5326eeb2a2cf7d34a377cf /src/backend/access/transam/xlog.c
parent8c95ae81fab11b75a611b57d6aaa0ef77e8b8e41 (diff)
downloadpostgresql-5df44d14ba9fd3f6149c3fa0919745c9e24bcffe.tar.gz
postgresql-5df44d14ba9fd3f6149c3fa0919745c9e24bcffe.zip
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.
Diffstat (limited to 'src/backend/access/transam/xlog.c')
0 files changed, 0 insertions, 0 deletions