- Notifications
You must be signed in to change notification settings - Fork4.9k
Commitc48008f
committed
Detect integer overflow while computing new array dimensions.
array_set_element() and related functions allow an array to beenlarged by assigning to subscripts outside the current array bounds.While these places were careful to check that the new bounds areallowable, they neglected to consider the risk of integer overflowin computing the new bounds. In edge cases, we could compute newbounds that are invalid but get past the subsequent checks,allowing bad things to happen. Memory stomps that are potentiallyexploitable for arbitrary code execution are possible, and so isdisclosure of server memory.To fix, perform the hazardous computations using overflow-detectingarithmetic routines, which fortunately exist in all still-supportedbranches.The test cases added for this generate (after patching) errors thatmention the value of MaxArraySize, which is platform-dependent.Rather than introduce multiple expected-files, use psql's VERBOSITYparameter to suppress the printing of the message text. v11 psqllacks that parameter, so omit the tests in that branch.Our thanks to Pedro Gallegos for reporting this problem.Security:CVE-2023-58691 parent8c6633f commitc48008f
File tree
3 files changed
+74
-24
lines changed- src
- backend/utils/adt
- include/utils
3 files changed
+74
-24
lines changedLines changed: 67 additions & 18 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
23 | 23 |
| |
24 | 24 |
| |
25 | 25 |
| |
| 26 | + | |
26 | 27 |
| |
27 | 28 |
| |
28 | 29 |
| |
| |||
2310 | 2311 |
| |
2311 | 2312 |
| |
2312 | 2313 |
| |
2313 |
| - | |
| 2314 | + | |
| 2315 | + | |
| 2316 | + | |
| 2317 | + | |
2314 | 2318 |
| |
2315 | 2319 |
| |
2316 | 2320 |
| |
2317 | 2321 |
| |
2318 | 2322 |
| |
2319 |
| - | |
2320 |
| - | |
| 2323 | + | |
| 2324 | + | |
| 2325 | + | |
| 2326 | + | |
| 2327 | + | |
| 2328 | + | |
| 2329 | + | |
| 2330 | + | |
2321 | 2331 |
| |
2322 | 2332 |
| |
2323 | 2333 |
| |
2324 | 2334 |
| |
2325 | 2335 |
| |
2326 | 2336 |
| |
2327 |
| - | |
2328 |
| - | |
| 2337 | + | |
| 2338 | + | |
| 2339 | + | |
| 2340 | + | |
| 2341 | + | |
| 2342 | + | |
| 2343 | + | |
| 2344 | + | |
| 2345 | + | |
2329 | 2346 |
| |
2330 | 2347 |
| |
2331 | 2348 |
| |
| |||
2568 | 2585 |
| |
2569 | 2586 |
| |
2570 | 2587 |
| |
2571 |
| - | |
| 2588 | + | |
| 2589 | + | |
| 2590 | + | |
| 2591 | + | |
2572 | 2592 |
| |
2573 | 2593 |
| |
2574 | 2594 |
| |
2575 | 2595 |
| |
2576 | 2596 |
| |
2577 |
| - | |
2578 |
| - | |
| 2597 | + | |
| 2598 | + | |
| 2599 | + | |
| 2600 | + | |
| 2601 | + | |
| 2602 | + | |
| 2603 | + | |
| 2604 | + | |
2579 | 2605 |
| |
2580 | 2606 |
| |
2581 | 2607 |
| |
2582 | 2608 |
| |
2583 | 2609 |
| |
2584 | 2610 |
| |
2585 | 2611 |
| |
2586 |
| - | |
2587 |
| - | |
| 2612 | + | |
| 2613 | + | |
| 2614 | + | |
| 2615 | + | |
| 2616 | + | |
| 2617 | + | |
| 2618 | + | |
| 2619 | + | |
| 2620 | + | |
2588 | 2621 |
| |
2589 | 2622 |
| |
2590 | 2623 |
| |
| |||
2866 | 2899 |
| |
2867 | 2900 |
| |
2868 | 2901 |
| |
2869 |
| - | |
| 2902 | + | |
| 2903 | + | |
| 2904 | + | |
| 2905 | + | |
2870 | 2906 |
| |
2871 | 2907 |
| |
2872 | 2908 |
| |
| |||
2881 | 2917 |
| |
2882 | 2918 |
| |
2883 | 2919 |
| |
2884 |
| - | |
2885 |
| - | |
2886 |
| - | |
2887 |
| - | |
| 2920 | + | |
| 2921 | + | |
| 2922 | + | |
| 2923 | + | |
| 2924 | + | |
| 2925 | + | |
| 2926 | + | |
| 2927 | + | |
2888 | 2928 |
| |
| 2929 | + | |
| 2930 | + | |
2889 | 2931 |
| |
2890 | 2932 |
| |
2891 | 2933 |
| |
2892 |
| - | |
| 2934 | + | |
| 2935 | + | |
| 2936 | + | |
| 2937 | + | |
| 2938 | + | |
| 2939 | + | |
| 2940 | + | |
| 2941 | + | |
| 2942 | + | |
| 2943 | + | |
2893 | 2944 |
| |
2894 |
| - | |
2895 |
| - | |
2896 | 2945 |
| |
2897 | 2946 |
| |
2898 | 2947 |
| |
|
Lines changed: 0 additions & 6 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
64 | 64 |
| |
65 | 65 |
| |
66 | 66 |
| |
67 |
| - | |
68 |
| - | |
69 |
| - | |
70 |
| - | |
71 | 67 |
| |
72 | 68 |
| |
73 | 69 |
| |
| |||
78 | 74 |
| |
79 | 75 |
| |
80 | 76 |
| |
81 |
| - | |
82 |
| - | |
83 | 77 |
| |
84 | 78 |
| |
85 | 79 |
| |
|
Lines changed: 7 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
69 | 69 |
| |
70 | 70 |
| |
71 | 71 |
| |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
72 | 79 |
| |
73 | 80 |
| |
74 | 81 |
| |
|
0 commit comments
Comments
(0)