forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commitf02b908
committed
Prevent integer overflows in array subscripting calculations.
While we were (mostly) careful about ensuring that the dimensions ofarrays aren't large enough to cause integer overflow, the lower boundvalues were generally not checked. This allows situations wherelower_bound + dimension overflows an integer. It seems that that'sharmless so far as array reading is concerned, except that arrayelements with subscripts notionally exceeding INT_MAX are inaccessible.However, it confuses various array-assignment logic, resulting in apotential for memory stomps.Fix by adding checks that array lower bounds aren't large enough tocause lower_bound + dimension to overflow. (Note: this results indisallowing cases where the last subscript position would be exactlyINT_MAX. In principle we could probably allow that, but there's a lotof code that computes lower_bound + dimension and would need adjustment.It seems doubtful that it's worth the trouble/risk to allow it.)Somewhat independently of that, array_set_element() was carelessabout possible overflow when checking the subscript of a fixed-lengtharray, creating a different route to memory stomps. Fix that too.Security:CVE-2021-320271 parent6206454 commitf02b908
File tree
5 files changed
+61
-16
lines changed- src
- backend
- executor
- utils/adt
- include/utils
5 files changed
+61
-16
lines changedLines changed: 4 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
2828 | 2828 |
| |
2829 | 2829 |
| |
2830 | 2830 |
| |
| 2831 | + | |
| 2832 | + | |
| 2833 | + | |
| 2834 | + | |
2831 | 2835 |
| |
2832 | 2836 |
| |
2833 | 2837 |
| |
|
Lines changed: 1 addition & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
411 | 411 |
| |
412 | 412 |
| |
413 | 413 |
| |
| 414 | + | |
414 | 415 |
| |
415 | 416 |
| |
416 | 417 |
| |
|
Lines changed: 24 additions & 16 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
372 | 372 |
| |
373 | 373 |
| |
374 | 374 |
| |
| 375 | + | |
| 376 | + | |
375 | 377 |
| |
376 | 378 |
| |
377 | 379 |
| |
| |||
1342 | 1344 |
| |
1343 | 1345 |
| |
1344 | 1346 |
| |
1345 |
| - | |
1346 |
| - | |
1347 |
| - | |
1348 |
| - | |
1349 |
| - | |
1350 |
| - | |
1351 |
| - | |
1352 |
| - | |
1353 |
| - | |
1354 |
| - | |
1355 |
| - | |
1356 |
| - | |
1357 |
| - | |
1358 |
| - | |
1359 | 1347 |
| |
1360 | 1348 |
| |
1361 | 1349 |
| |
1362 | 1350 |
| |
| 1351 | + | |
1363 | 1352 |
| |
1364 | 1353 |
| |
1365 | 1354 |
| |
| |||
2265 | 2254 |
| |
2266 | 2255 |
| |
2267 | 2256 |
| |
2268 |
| - | |
| 2257 | + | |
2269 | 2258 |
| |
2270 | 2259 |
| |
2271 | 2260 |
| |
| |||
2380 | 2369 |
| |
2381 | 2370 |
| |
2382 | 2371 |
| |
| 2372 | + | |
| 2373 | + | |
| 2374 | + | |
| 2375 | + | |
2383 | 2376 |
| |
2384 | 2377 |
| |
2385 | 2378 |
| |
2386 |
| - | |
2387 | 2379 |
| |
2388 | 2380 |
| |
2389 | 2381 |
| |
| |||
2641 | 2633 |
| |
2642 | 2634 |
| |
2643 | 2635 |
| |
| 2636 | + | |
| 2637 | + | |
| 2638 | + | |
| 2639 | + | |
| 2640 | + | |
| 2641 | + | |
| 2642 | + | |
2644 | 2643 |
| |
2645 | 2644 |
| |
2646 | 2645 |
| |
| |||
2960 | 2959 |
| |
2961 | 2960 |
| |
2962 | 2961 |
| |
| 2962 | + | |
2963 | 2963 |
| |
2964 | 2964 |
| |
2965 | 2965 |
| |
| |||
3374 | 3374 |
| |
3375 | 3375 |
| |
3376 | 3376 |
| |
| 3377 | + | |
3377 | 3378 |
| |
| 3379 | + | |
3378 | 3380 |
| |
3379 | 3381 |
| |
3380 | 3382 |
| |
| |||
5449 | 5451 |
| |
5450 | 5452 |
| |
5451 | 5453 |
| |
| 5454 | + | |
| 5455 | + | |
| 5456 | + | |
| 5457 | + | |
5452 | 5458 |
| |
5453 | 5459 |
| |
5454 | 5460 |
| |
| |||
5878 | 5884 |
| |
5879 | 5885 |
| |
5880 | 5886 |
| |
| 5887 | + | |
5881 | 5888 |
| |
| 5889 | + | |
5882 | 5890 |
| |
5883 | 5891 |
| |
5884 | 5892 |
| |
|
Lines changed: 31 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
16 | 16 |
| |
17 | 17 |
| |
18 | 18 |
| |
| 19 | + | |
19 | 20 |
| |
20 | 21 |
| |
21 | 22 |
| |
| |||
111 | 112 |
| |
112 | 113 |
| |
113 | 114 |
| |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
114 | 145 |
| |
115 | 146 |
| |
116 | 147 |
| |
|
Lines changed: 1 addition & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
443 | 443 |
| |
444 | 444 |
| |
445 | 445 |
| |
| 446 | + | |
446 | 447 |
| |
447 | 448 |
| |
448 | 449 |
| |
|
0 commit comments
Comments
(0)