forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commitebbd499
committed
Be more wary about OpenSSL not setting errno on error.
OpenSSL will sometimes return SSL_ERROR_SYSCALL without having seterrno; this is apparently a reflection of recv(2)'s habit of notsetting errno when reporting EOF. Ensure that we treat such casesthe same as read EOF. Previously, we'd frequently report them like"could not accept SSL connection: Success" which is confusing, orworse report them with an unrelated errno left over from someprevious syscall.To fix, ensure that errno is zeroed immediately before the call,and report its value only when it's not zero afterwards; otherwisereport EOF.For consistency, I've applied the same coding pattern in libpq'spqsecure_raw_read(). Bare recv(2) shouldn't really return -1 withoutsetting errno, but in case it does we might as well cope.Per report from Andres Freund. Back-patch to all supported versions.Discussion:https://postgr.es/m/20231208181451.deqnflwxqoehhxpe@awork3.anarazel.de1 parent01cc92f commitebbd499
File tree
4 files changed
+45
-14
lines changed- src
- backend/libpq
- interfaces/libpq
4 files changed
+45
-14
lines changedLines changed: 11 additions & 4 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
460 | 460 |
| |
461 | 461 |
| |
462 | 462 |
| |
| 463 | + | |
463 | 464 |
| |
464 | 465 |
| |
465 | 466 |
| |
| |||
496 | 497 |
| |
497 | 498 |
| |
498 | 499 |
| |
499 |
| - | |
| 500 | + | |
500 | 501 |
| |
501 | 502 |
| |
502 | 503 |
| |
| |||
732 | 733 |
| |
733 | 734 |
| |
734 | 735 |
| |
735 |
| - | |
| 736 | + | |
736 | 737 |
| |
737 | 738 |
| |
738 | 739 |
| |
| |||
790 | 791 |
| |
791 | 792 |
| |
792 | 793 |
| |
793 |
| - | |
794 |
| - | |
| 794 | + | |
| 795 | + | |
| 796 | + | |
| 797 | + | |
| 798 | + | |
| 799 | + | |
| 800 | + | |
| 801 | + | |
795 | 802 |
| |
796 | 803 |
| |
797 | 804 |
| |
|
Lines changed: 16 additions & 6 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
936 | 936 |
| |
937 | 937 |
| |
938 | 938 |
| |
| 939 | + | |
| 940 | + | |
939 | 941 |
| |
940 | 942 |
| |
941 | 943 |
| |
| |||
948 | 950 |
| |
949 | 951 |
| |
950 | 952 |
| |
| 953 | + | |
| 954 | + | |
951 | 955 |
| |
952 |
| - | |
953 |
| - | |
954 |
| - | |
| 956 | + | |
| 957 | + | |
| 958 | + | |
| 959 | + | |
955 | 960 |
| |
956 | 961 |
| |
957 | 962 |
| |
| |||
1028 | 1033 |
| |
1029 | 1034 |
| |
1030 | 1035 |
| |
| 1036 | + | |
| 1037 | + | |
1031 | 1038 |
| |
1032 | 1039 |
| |
1033 | 1040 |
| |
| |||
1044 | 1051 |
| |
1045 | 1052 |
| |
1046 | 1053 |
| |
| 1054 | + | |
| 1055 | + | |
1047 | 1056 |
| |
1048 |
| - | |
1049 |
| - | |
1050 |
| - | |
| 1057 | + | |
| 1058 | + | |
| 1059 | + | |
| 1060 | + | |
1051 | 1061 |
| |
1052 | 1062 |
| |
1053 | 1063 |
| |
|
Lines changed: 11 additions & 4 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
207 | 207 |
| |
208 | 208 |
| |
209 | 209 |
| |
210 |
| - | |
| 210 | + | |
211 | 211 |
| |
212 | 212 |
| |
213 | 213 |
| |
| |||
308 | 308 |
| |
309 | 309 |
| |
310 | 310 |
| |
311 |
| - | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
312 | 318 |
| |
313 | 319 |
| |
314 | 320 |
| |
| |||
1523 | 1529 |
| |
1524 | 1530 |
| |
1525 | 1531 |
| |
1526 |
| - | |
| 1532 | + | |
| 1533 | + | |
1527 | 1534 |
| |
1528 | 1535 |
| |
1529 | 1536 |
| |
1530 |
| - | |
| 1537 | + | |
1531 | 1538 |
| |
1532 | 1539 |
| |
1533 | 1540 |
| |
|
Lines changed: 7 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
233 | 233 |
| |
234 | 234 |
| |
235 | 235 |
| |
| 236 | + | |
| 237 | + | |
236 | 238 |
| |
237 | 239 |
| |
238 | 240 |
| |
| |||
259 | 261 |
| |
260 | 262 |
| |
261 | 263 |
| |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
262 | 269 |
| |
263 | 270 |
| |
264 | 271 |
| |
|
0 commit comments
Comments
(0)