- Notifications
You must be signed in to change notification settings - Fork4.9k
Commitf0c7b78
committed
Fix two errors with nested CASE/WHEN constructs.
ExecEvalCase() tried to save a cycle or two by passing&econtext->caseValue_isNull as the isNull argument to its sub-evaluation ofthe CASE value expression. If that subexpression itself contained a CASE,then *isNull was an alias for econtext->caseValue_isNull within therecursive call of ExecEvalCase(), leading to confusion about whether theinner call's caseValue was null or not. In the worst case this could leadto a core dump due to dereferencing a null pointer. Fix by not assigningto the global variable until control comes back from the subexpression.Also, avoid using the passed-in isNull pointer transiently for evaluationof WHEN expressions. (Either one of these changes would have beensufficient to fix the known misbehavior, but it's clear now that each ofthese choices was in itself dangerous coding practice and best avoided.There do not seem to be any similar hazards elsewhere in execQual.c.)Also, it was possible for inlining of a SQL function that implements theequality operator used for a CASE comparison to result in one CASEexpression's CaseTestExpr node being inserted inside another CASEexpression. This would certainly result in wrong answers since theimproperly nested CaseTestExpr would be caused to return the inner CASE'scomparison value not the outer's. If the CASE values were of differentdata types, a crash might result; moreover such situations could be abusedto allow disclosure of portions of server memory. To fix, teachinline_function to check for "bare" CaseTestExpr nodes in the arguments ofa function to be inlined, and avoid inlining if there are any.Heikki Linnakangas, Michael Paquier, Tom LaneReport:https://github.com/greenplum-db/gpdb/pull/327Report: <4DDCEEB8.50602@enterprisedb.com>Security:CVE-2016-54231 parentfcd15f1 commitf0c7b78
File tree
4 files changed
+185
-5
lines changed- src
- backend
- executor
- optimizer/util
- test/regress
- expected
- sql
4 files changed
+185
-5
lines changedLines changed: 17 additions & 5 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
2970 | 2970 |
| |
2971 | 2971 |
| |
2972 | 2972 |
| |
2973 |
| - | |
| 2973 | + | |
2974 | 2974 |
| |
2975 |
| - | |
| 2975 | + | |
| 2976 | + | |
| 2977 | + | |
| 2978 | + | |
| 2979 | + | |
| 2980 | + | |
| 2981 | + | |
| 2982 | + | |
| 2983 | + | |
2976 | 2984 |
| |
2977 | 2985 |
| |
2978 | 2986 |
| |
2979 | 2987 |
| |
2980 | 2988 |
| |
2981 | 2989 |
| |
| 2990 | + | |
| 2991 | + | |
2982 | 2992 |
| |
2983 | 2993 |
| |
2984 |
| - | |
| 2994 | + | |
2985 | 2995 |
| |
| 2996 | + | |
2986 | 2997 |
| |
2987 | 2998 |
| |
2988 | 2999 |
| |
| |||
2994 | 3005 |
| |
2995 | 3006 |
| |
2996 | 3007 |
| |
| 3008 | + | |
2997 | 3009 |
| |
2998 | 3010 |
| |
2999 | 3011 |
| |
3000 |
| - | |
| 3012 | + | |
3001 | 3013 |
| |
3002 | 3014 |
| |
3003 | 3015 |
| |
3004 | 3016 |
| |
3005 | 3017 |
| |
3006 | 3018 |
| |
3007 | 3019 |
| |
3008 |
| - | |
| 3020 | + | |
3009 | 3021 |
| |
3010 | 3022 |
| |
3011 | 3023 |
| |
|
Lines changed: 81 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
106 | 106 |
| |
107 | 107 |
| |
108 | 108 |
| |
| 109 | + | |
| 110 | + | |
109 | 111 |
| |
110 | 112 |
| |
111 | 113 |
| |
| |||
1334 | 1336 |
| |
1335 | 1337 |
| |
1336 | 1338 |
| |
| 1339 | + | |
| 1340 | + | |
| 1341 | + | |
| 1342 | + | |
| 1343 | + | |
| 1344 | + | |
| 1345 | + | |
| 1346 | + | |
| 1347 | + | |
| 1348 | + | |
| 1349 | + | |
| 1350 | + | |
| 1351 | + | |
| 1352 | + | |
| 1353 | + | |
| 1354 | + | |
| 1355 | + | |
| 1356 | + | |
| 1357 | + | |
| 1358 | + | |
| 1359 | + | |
| 1360 | + | |
| 1361 | + | |
| 1362 | + | |
| 1363 | + | |
| 1364 | + | |
| 1365 | + | |
| 1366 | + | |
| 1367 | + | |
| 1368 | + | |
| 1369 | + | |
| 1370 | + | |
| 1371 | + | |
| 1372 | + | |
| 1373 | + | |
| 1374 | + | |
| 1375 | + | |
| 1376 | + | |
| 1377 | + | |
| 1378 | + | |
| 1379 | + | |
| 1380 | + | |
| 1381 | + | |
| 1382 | + | |
| 1383 | + | |
| 1384 | + | |
| 1385 | + | |
| 1386 | + | |
| 1387 | + | |
| 1388 | + | |
| 1389 | + | |
| 1390 | + | |
| 1391 | + | |
| 1392 | + | |
| 1393 | + | |
| 1394 | + | |
| 1395 | + | |
| 1396 | + | |
| 1397 | + | |
| 1398 | + | |
| 1399 | + | |
| 1400 | + | |
| 1401 | + | |
| 1402 | + | |
| 1403 | + | |
| 1404 | + | |
| 1405 | + | |
| 1406 | + | |
| 1407 | + | |
| 1408 | + | |
1337 | 1409 |
| |
1338 | 1410 |
| |
1339 | 1411 |
| |
| |||
4178 | 4250 |
| |
4179 | 4251 |
| |
4180 | 4252 |
| |
| 4253 | + | |
| 4254 | + | |
4181 | 4255 |
| |
4182 | 4256 |
| |
4183 | 4257 |
| |
| |||
4372 | 4446 |
| |
4373 | 4447 |
| |
4374 | 4448 |
| |
| 4449 | + | |
| 4450 | + | |
| 4451 | + | |
| 4452 | + | |
| 4453 | + | |
| 4454 | + | |
| 4455 | + | |
4375 | 4456 |
| |
4376 | 4457 |
| |
4377 | 4458 |
| |
|
Lines changed: 44 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
296 | 296 |
| |
297 | 297 |
| |
298 | 298 |
| |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
299 | 338 |
| |
300 | 339 |
| |
301 | 340 |
| |
302 | 341 |
| |
303 | 342 |
| |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + |
Lines changed: 43 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
156 | 156 |
| |
157 | 157 |
| |
158 | 158 |
| |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
159 | 197 |
| |
160 | 198 |
| |
161 | 199 |
| |
162 | 200 |
| |
163 | 201 |
| |
164 | 202 |
| |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + |
0 commit comments
Comments
(0)