forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork0
Commit72d4fd0
committed
Fix behavior when converting a float infinity to numeric.
float8_numeric() and float4_numeric() failed to consider the possibilitythat the input is an IEEE infinity. The results depended on theplatform-specific behavior of sprintf(): on most platforms you'd getsomething likeERROR: invalid input syntax for type numeric: "inf"but at least on Windows it's possible for the conversion to succeed anddeliver a finite value (typically 1), due to a nonstandard output formatfrom sprintf and lack of syntax error checking in these functions.Since our numeric type lacks the concept of infinity, a suitable conversionis impossible; the best thing to do is throw an explicit error beforeletting sprintf do its thing.While at it, let's use snprintf not sprintf. Overrunning the buffershould be impossible if sprintf does what it's supposed to, but thisis cheap insurance against a stack smash if it doesn't.Problem reported by Taiki Kondo. Patch by me based on fix suggestionfrom KaiGai Kohei. Back-patch to all supported branches.Discussion:https://postgr.es/m/12A9442FBAE80D4E8953883E0B84E088C8C7A2@BPXM01GP.gisp.nec.co.jp1 parent6525a3a commit72d4fd0
File tree
3 files changed
+41
-2
lines changed- src
- backend/utils/adt
- test/regress
- expected
- sql
3 files changed
+41
-2
lines changedLines changed: 12 additions & 2 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
2438 | 2438 |
| |
2439 | 2439 |
| |
2440 | 2440 |
| |
2441 |
| - | |
| 2441 | + | |
| 2442 | + | |
| 2443 | + | |
| 2444 | + | |
| 2445 | + | |
| 2446 | + | |
2442 | 2447 |
| |
2443 | 2448 |
| |
2444 | 2449 |
| |
| |||
2500 | 2505 |
| |
2501 | 2506 |
| |
2502 | 2507 |
| |
2503 |
| - | |
| 2508 | + | |
| 2509 | + | |
| 2510 | + | |
| 2511 | + | |
| 2512 | + | |
| 2513 | + | |
2504 | 2514 |
| |
2505 | 2515 |
| |
2506 | 2516 |
| |
|
Lines changed: 21 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
708 | 708 |
| |
709 | 709 |
| |
710 | 710 |
| |
| 711 | + | |
| 712 | + | |
| 713 | + | |
| 714 | + | |
| 715 | + | |
| 716 | + | |
| 717 | + | |
| 718 | + | |
| 719 | + | |
| 720 | + | |
| 721 | + | |
| 722 | + | |
| 723 | + | |
| 724 | + | |
| 725 | + | |
| 726 | + | |
| 727 | + | |
| 728 | + | |
| 729 | + | |
| 730 | + | |
| 731 | + | |
711 | 732 |
| |
712 | 733 |
| |
713 | 734 |
| |
|
Lines changed: 8 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
655 | 655 |
| |
656 | 656 |
| |
657 | 657 |
| |
| 658 | + | |
| 659 | + | |
| 660 | + | |
| 661 | + | |
| 662 | + | |
| 663 | + | |
| 664 | + | |
| 665 | + | |
658 | 666 |
| |
659 | 667 |
| |
660 | 668 |
| |
|
0 commit comments
Comments
(0)