forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commit18c0b4e
committed
Fix array- and path-creating functions to ensure padding bytes are zeroes.
Per recent discussion, it's important for all computed datums (not only theresults of input functions) to not contain any ill-defined (uninitialized)bits. Failing to ensure that can result in equal() reporting thatsemantically indistinguishable Consts are not equal, which in turn leads tobizarre and undesirable planner behavior, such as in a recent example fromDavid Johnston. We might eventually try to fix this in a general manner byallowing datatypes to define identity-testing functions, but for now thepath of least resistance is to expect datatypes to force all unused bitsinto consistent states.Per some testing by Noah Misch, array and path functions seem to be theonly ones presenting risks at the moment, so I looked through all thefunctions in adt/array*.c and geo_ops.c and fixed them as necessary. Inthe array functions, the easiest/safest fix is to allocate result arrayswith palloc0 instead of palloc. Possibly in future someone will want tolook into whether we can just zero the padding bytes, but that looks toocomplex for a back-patchable fix. In the path functions, we already had aprecedent in path_in for just zeroing the one known pad field, so duplicatethat code as needed.Back-patch to all supported branches.1 parent348c10e commit18c0b4e
File tree
3 files changed
+14
-8
lines changed- src/backend/utils/adt
3 files changed
+14
-8
lines changedLines changed: 1 addition & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
375 | 375 |
| |
376 | 376 |
| |
377 | 377 |
| |
378 |
| - | |
| 378 | + | |
379 | 379 |
| |
380 | 380 |
| |
381 | 381 |
| |
|
Lines changed: 7 additions & 7 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
1339 | 1339 |
| |
1340 | 1340 |
| |
1341 | 1341 |
| |
1342 |
| - | |
| 1342 | + | |
1343 | 1343 |
| |
1344 | 1344 |
| |
1345 | 1345 |
| |
| |||
1977 | 1977 |
| |
1978 | 1978 |
| |
1979 | 1979 |
| |
1980 |
| - | |
| 1980 | + | |
1981 | 1981 |
| |
1982 | 1982 |
| |
1983 | 1983 |
| |
| |||
2230 | 2230 |
| |
2231 | 2231 |
| |
2232 | 2232 |
| |
2233 |
| - | |
| 2233 | + | |
2234 | 2234 |
| |
2235 | 2235 |
| |
2236 | 2236 |
| |
| |||
2560 | 2560 |
| |
2561 | 2561 |
| |
2562 | 2562 |
| |
2563 |
| - | |
| 2563 | + | |
2564 | 2564 |
| |
2565 | 2565 |
| |
2566 | 2566 |
| |
| |||
2819 | 2819 |
| |
2820 | 2820 |
| |
2821 | 2821 |
| |
2822 |
| - | |
| 2822 | + | |
2823 | 2823 |
| |
2824 | 2824 |
| |
2825 | 2825 |
| |
| |||
2955 | 2955 |
| |
2956 | 2956 |
| |
2957 | 2957 |
| |
2958 |
| - | |
| 2958 | + | |
2959 | 2959 |
| |
2960 | 2960 |
| |
2961 | 2961 |
| |
| |||
2979 | 2979 |
| |
2980 | 2980 |
| |
2981 | 2981 |
| |
2982 |
| - | |
| 2982 | + | |
2983 | 2983 |
| |
2984 | 2984 |
| |
2985 | 2985 |
| |
|
Lines changed: 6 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
1478 | 1478 |
| |
1479 | 1479 |
| |
1480 | 1480 |
| |
| 1481 | + | |
| 1482 | + | |
1481 | 1483 |
| |
1482 | 1484 |
| |
1483 | 1485 |
| |
| |||
4253 | 4255 |
| |
4254 | 4256 |
| |
4255 | 4257 |
| |
| 4258 | + | |
| 4259 | + | |
4256 | 4260 |
| |
4257 | 4261 |
| |
4258 | 4262 |
| |
| |||
4486 | 4490 |
| |
4487 | 4491 |
| |
4488 | 4492 |
| |
| 4493 | + | |
| 4494 | + | |
4489 | 4495 |
| |
4490 | 4496 |
| |
4491 | 4497 |
| |
|
0 commit comments
Comments
(0)