forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commit43f1d2a
committed
Improve libpq's handling of OOM during error message construction.
Commitffa2e46 changed libpq so that multiple error reportsoccurring during one operation (a connection attempt or query)are accumulated in conn->errorMessage, where before new onesusually replaced any prior error. At least in theory, that makesus more vulnerable to running out of memory for the errorMessagebuffer. If it did happen, the user would be left with just anempty-string error report, which is pretty unhelpful.We can improve this by relying on pqexpbuffer.c's existing "brokenbuffer" convention to track whether we've hit OOM for the currentoperation's error string, and then substituting a constant "out ofmemory" string in the small number of places where the errorMessageis read out.While at it, apply the same method to similar OOM cases inpqInternalNotice and pqGetErrorNotice3.Back-patch to v14 whereffa2e46 came in. In principle this couldgo back further; but in view of the lack of field reports, thehazard seems negligible in older branches.Discussion:https://postgr.es/m/530153.1627425648@sss.pgh.pa.us1 parentc42d3d0 commit43f1d2a
File tree
4 files changed
+48
-19
lines changed- src/interfaces/libpq
4 files changed
+48
-19
lines changedLines changed: 8 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
6743 | 6743 |
| |
6744 | 6744 |
| |
6745 | 6745 |
| |
| 6746 | + | |
| 6747 | + | |
| 6748 | + | |
| 6749 | + | |
| 6750 | + | |
| 6751 | + | |
| 6752 | + | |
| 6753 | + | |
6746 | 6754 |
| |
6747 | 6755 |
| |
6748 | 6756 |
| |
|
Lines changed: 28 additions & 14 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
191 | 191 |
| |
192 | 192 |
| |
193 | 193 |
| |
194 |
| - | |
| 194 | + | |
195 | 195 |
| |
196 | 196 |
| |
197 | 197 |
| |
| |||
662 | 662 |
| |
663 | 663 |
| |
664 | 664 |
| |
665 |
| - | |
| 665 | + | |
666 | 666 |
| |
| 667 | + | |
| 668 | + | |
667 | 669 |
| |
668 | 670 |
| |
669 |
| - | |
670 |
| - | |
| 671 | + | |
| 672 | + | |
| 673 | + | |
| 674 | + | |
| 675 | + | |
| 676 | + | |
| 677 | + | |
| 678 | + | |
| 679 | + | |
| 680 | + | |
| 681 | + | |
| 682 | + | |
| 683 | + | |
| 684 | + | |
671 | 685 |
| |
672 |
| - | |
| 686 | + | |
673 | 687 |
| |
674 | 688 |
| |
675 | 689 |
| |
| |||
852 | 866 |
| |
853 | 867 |
| |
854 | 868 |
| |
855 |
| - | |
856 |
| - | |
| 869 | + | |
| 870 | + | |
857 | 871 |
| |
858 | 872 |
| |
859 | 873 |
| |
860 |
| - | |
861 | 874 |
| |
| 875 | + | |
| 876 | + | |
862 | 877 |
| |
863 |
| - | |
864 |
| - | |
865 |
| - | |
866 |
| - | |
867 |
| - | |
| 878 | + | |
| 879 | + | |
| 880 | + | |
| 881 | + | |
868 | 882 |
| |
869 | 883 |
| |
870 | 884 |
| |
| |||
2122 | 2136 |
| |
2123 | 2137 |
| |
2124 | 2138 |
| |
2125 |
| - | |
| 2139 | + | |
2126 | 2140 |
| |
2127 | 2141 |
| |
2128 | 2142 |
| |
|
Lines changed: 11 additions & 4 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
967 | 967 |
| |
968 | 968 |
| |
969 | 969 |
| |
970 |
| - | |
| 970 | + | |
971 | 971 |
| |
972 | 972 |
| |
973 | 973 |
| |
974 | 974 |
| |
975 |
| - | |
| 975 | + | |
976 | 976 |
| |
977 | 977 |
| |
978 | 978 |
| |
| |||
981 | 981 |
| |
982 | 982 |
| |
983 | 983 |
| |
984 |
| - | |
985 |
| - | |
| 984 | + | |
| 985 | + | |
| 986 | + | |
| 987 | + | |
| 988 | + | |
| 989 | + | |
| 990 | + | |
| 991 | + | |
| 992 | + | |
986 | 993 |
| |
987 | 994 |
| |
988 | 995 |
| |
|
Lines changed: 1 addition & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
642 | 642 |
| |
643 | 643 |
| |
644 | 644 |
| |
645 |
| - | |
| 645 | + | |
646 | 646 |
| |
647 | 647 |
| |
648 | 648 |
| |
|
0 commit comments
Comments
(0)