forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork0
Commite5d64fd
committed
Tighten parsing of datetime input.
ParseFraction only expects to deal with fields that contain a decimalpoint and digit(s). However it's possible in some edge cases for itto be passed input that doesn't look like that. In particular theinput could look like a valid floating-point number, such as ".123e6".strtod() will happily eat that, possibly producing a result that isnot within the expected range 0..1, which can result in integeroverflow in the callers. That doesn't have any security consequences,but it's still not very desirable. Fix by checking that the inputhas the expected form.Similarly, DecodeNumberField only expects to deal with fields thatcontain a decimal point and digit(s), but it's sometimes abused toparse strings that might not look like that. This could result infailure to reject bogus input, yielding silly results. Again, fixby rejecting input that doesn't look as-expected. That decisionalso means that we can affirmatively answer the very old commentquestioning whether we couldn't save some duplicative code byusing ParseFractionalSecond here.While these changes should only reject input that nobody wouldconsider valid, it still doesn't seem like a change to make instable branches. Apply to HEAD only.Reported-by: Evgeniy Gorbanev <gorbanev.es@gmail.com>Author: Tom Lane <tgl@sss.pgh.pa.us>Discussion:https://postgr.es/m/1328335.1748371099@sss.pgh.pa.us1 parentbe86ca1 commite5d64fd
File tree
3 files changed
+38
-19
lines changed- src
- backend/utils/adt
- test/regress
- expected
- sql
3 files changed
+38
-19
lines changedLines changed: 25 additions & 19 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
702 | 702 |
| |
703 | 703 |
| |
704 | 704 |
| |
| 705 | + | |
| 706 | + | |
| 707 | + | |
| 708 | + | |
| 709 | + | |
| 710 | + | |
| 711 | + | |
| 712 | + | |
| 713 | + | |
705 | 714 |
| |
706 | 715 |
| |
707 |
| - | |
| 716 | + | |
708 | 717 |
| |
709 | 718 |
| |
710 | 719 |
| |
| |||
2958 | 2967 |
| |
2959 | 2968 |
| |
2960 | 2969 |
| |
| 2970 | + | |
| 2971 | + | |
| 2972 | + | |
| 2973 | + | |
| 2974 | + | |
| 2975 | + | |
| 2976 | + | |
| 2977 | + | |
| 2978 | + | |
| 2979 | + | |
2961 | 2980 |
| |
2962 | 2981 |
| |
2963 | 2982 |
| |
2964 | 2983 |
| |
2965 | 2984 |
| |
2966 | 2985 |
| |
2967 |
| - | |
2968 |
| - | |
2969 |
| - | |
2970 |
| - | |
2971 |
| - | |
2972 |
| - | |
2973 |
| - | |
2974 |
| - | |
2975 |
| - | |
2976 |
| - | |
2977 |
| - | |
2978 |
| - | |
| 2986 | + | |
2979 | 2987 |
| |
2980 |
| - | |
2981 |
| - | |
2982 |
| - | |
2983 |
| - | |
2984 |
| - | |
2985 |
| - | |
| 2988 | + | |
| 2989 | + | |
| 2990 | + | |
| 2991 | + | |
2986 | 2992 |
| |
2987 | 2993 |
| |
2988 | 2994 |
| |
|
Lines changed: 9 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
467 | 467 |
| |
468 | 468 |
| |
469 | 469 |
| |
| 470 | + | |
| 471 | + | |
| 472 | + | |
| 473 | + | |
| 474 | + | |
| 475 | + | |
| 476 | + | |
| 477 | + | |
| 478 | + | |
470 | 479 |
| |
471 | 480 |
| |
472 | 481 |
| |
|
Lines changed: 4 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
102 | 102 |
| |
103 | 103 |
| |
104 | 104 |
| |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
105 | 109 |
| |
106 | 110 |
| |
107 | 111 |
| |
|
0 commit comments
Comments
(0)