- Notifications
You must be signed in to change notification settings - Fork4.9k
Commitccbb01f
committed
pgbench: avoid FD_ISSET on an invalid file descriptor
The original code wasn't careful to test the file descriptor returned byPQsocket() for an invalid socket. If an invalid socket did turn up,that would amount to calling FD_ISSET with fd = -1, whereby undefinedbehavior can be invoked.To fix, test file descriptor for validity and stop further processing ifthat fails.Problem noticed by Coverity.There is an existing FD_ISSET callsite that does check for invalidsockets beforehand, but the error message reported by it wasstrerror(errno); in testing the aforementioned change, that turns out toresult in "bad socket: Success" which isn't terribly helpful. Insteaduse PQerrorMessage() in both places which is more likely to contain anuseful error message.Backpatch-through: 9.1.1 parente3ad502 commitccbb01f
1 file changed
+15
-5
lines changedLines changed: 15 additions & 5 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
3231 | 3231 |
| |
3232 | 3232 |
| |
3233 | 3233 |
| |
3234 |
| - | |
| 3234 | + | |
3235 | 3235 |
| |
3236 | 3236 |
| |
3237 | 3237 |
| |
| |||
3299 | 3299 |
| |
3300 | 3300 |
| |
3301 | 3301 |
| |
3302 |
| - | |
3303 |
| - | |
| 3302 | + | |
3304 | 3303 |
| |
3305 |
| - | |
3306 |
| - | |
| 3304 | + | |
| 3305 | + | |
| 3306 | + | |
| 3307 | + | |
| 3308 | + | |
| 3309 | + | |
| 3310 | + | |
| 3311 | + | |
| 3312 | + | |
| 3313 | + | |
| 3314 | + | |
| 3315 | + | |
| 3316 | + | |
3307 | 3317 |
| |
3308 | 3318 |
| |
3309 | 3319 |
| |
|
0 commit comments
Comments
(0)