- Notifications
You must be signed in to change notification settings - Fork4.9k
Commit36a3be6
committed
Fix new and latent bugs with errno handling in secure_read/secure_write.
These functions must be careful that they return the intended value oferrno to their callers. There were several scenarios where this mightnot happen:1. The recent SSL renegotiation patch added a hunk of code that wouldexecute after setting errno. In the first place, it's doubtful that weshould consider renegotiation to be successfully completed after a failure,and in the second, there's no real guarantee that the called OpenSSLroutines wouldn't clobber errno. Fix by not executing that hunk exceptduring success exit.2. errno was left in an unknown state in case of an unrecognized returncode from SSL_get_error(). While this is a "can't happen" case, it seemslike a good idea to be sure we know what would happen, so reset errno toECONNRESET in such cases. (The corresponding code in libpq's fe-secure.calready did this.)3. There was an (undocumented) assumption that client_read_ended() wouldn'tchange errno. While true in the current state of the code, this seems lessthan future-proof. Add explicit saving/restoring of errno to make surethat changes in the called functions won't break things.I see no need to back-patch, since#1 is new code and the other two issuesare mostly hypothetical.Per discussion with Amit Kapila.1 parent08d1b22 commit36a3be6
2 files changed
+27
-16
lines changedLines changed: 21 additions & 16 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
295 | 295 |
| |
296 | 296 |
| |
297 | 297 |
| |
| 298 | + | |
298 | 299 |
| |
299 | 300 |
| |
300 | 301 |
| |
| |||
416 | 417 |
| |
417 | 418 |
| |
418 | 419 |
| |
| 420 | + | |
419 | 421 |
| |
420 | 422 |
| |
421 | 423 |
| |
422 | 424 |
| |
423 |
| - | |
424 |
| - | |
425 |
| - | |
| 425 | + | |
426 | 426 |
| |
427 |
| - | |
428 |
| - | |
429 |
| - | |
| 427 | + | |
| 428 | + | |
| 429 | + | |
| 430 | + | |
| 431 | + | |
| 432 | + | |
| 433 | + | |
430 | 434 |
| |
431 |
| - | |
432 |
| - | |
433 |
| - | |
434 |
| - | |
435 |
| - | |
436 |
| - | |
437 |
| - | |
438 |
| - | |
439 |
| - | |
440 |
| - | |
| 435 | + | |
| 436 | + | |
| 437 | + | |
| 438 | + | |
| 439 | + | |
| 440 | + | |
| 441 | + | |
| 442 | + | |
| 443 | + | |
| 444 | + | |
| 445 | + | |
441 | 446 |
| |
442 | 447 |
| |
443 | 448 |
| |
|
Lines changed: 6 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
526 | 526 |
| |
527 | 527 |
| |
528 | 528 |
| |
| 529 | + | |
| 530 | + | |
529 | 531 |
| |
530 | 532 |
| |
531 | 533 |
| |
532 | 534 |
| |
533 | 535 |
| |
534 | 536 |
| |
| 537 | + | |
| 538 | + | |
535 | 539 |
| |
536 | 540 |
| |
537 | 541 |
| |
538 | 542 |
| |
| 543 | + | |
| 544 | + | |
539 | 545 |
| |
540 | 546 |
| |
541 | 547 |
| |
|
0 commit comments
Comments
(0)