Commit 4338ac8
committed
Fix assorted integer-overflow hazards in varbit.c.
bitshiftright() and bitshiftleft() would recursively call each other
infinitely if the user passed INT_MIN for the shift amount, due to integer
overflow in negating the shift amount. To fix, clamp to -VARBITMAXLEN.
That doesn't change the results since any shift distance larger than the
input bit string's length produces an all-zeroes result.
Also fix some places that seemed inadequately paranoid about input typmods
exceeding VARBITMAXLEN. While a typmod accepted by anybit_typmodin() will
certainly be much less than that, at least some of these spots are
reachable with user-chosen integer values.
Andreas Seltenreich and Tom Lane
Discussion: <87d1j2zqtz.fsf@credativ.de>1 parent a209d6d commit 4338ac8
1 file changed
+15
-5
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
305 | 305 | | |
306 | 306 | | |
307 | 307 | | |
308 | | - | |
| 308 | + | |
309 | 309 | | |
310 | 310 | | |
311 | 311 | | |
| |||
368 | 368 | | |
369 | 369 | | |
370 | 370 | | |
371 | | - | |
| 371 | + | |
372 | 372 | | |
373 | 373 | | |
374 | 374 | | |
| |||
621 | 621 | | |
622 | 622 | | |
623 | 623 | | |
624 | | - | |
| 624 | + | |
625 | 625 | | |
626 | 626 | | |
627 | 627 | | |
| |||
1387 | 1387 | | |
1388 | 1388 | | |
1389 | 1389 | | |
| 1390 | + | |
| 1391 | + | |
| 1392 | + | |
| 1393 | + | |
1390 | 1394 | | |
1391 | 1395 | | |
1392 | 1396 | | |
| 1397 | + | |
1393 | 1398 | | |
1394 | 1399 | | |
1395 | 1400 | | |
| |||
1447 | 1452 | | |
1448 | 1453 | | |
1449 | 1454 | | |
| 1455 | + | |
| 1456 | + | |
| 1457 | + | |
| 1458 | + | |
1450 | 1459 | | |
1451 | 1460 | | |
1452 | 1461 | | |
| 1462 | + | |
1453 | 1463 | | |
1454 | 1464 | | |
1455 | 1465 | | |
| |||
1507 | 1517 | | |
1508 | 1518 | | |
1509 | 1519 | | |
1510 | | - | |
| 1520 | + | |
1511 | 1521 | | |
1512 | 1522 | | |
1513 | 1523 | | |
| |||
1587 | 1597 | | |
1588 | 1598 | | |
1589 | 1599 | | |
1590 | | - | |
| 1600 | + | |
1591 | 1601 | | |
1592 | 1602 | | |
1593 | 1603 | | |
| |||
0 commit comments