Commit d7056bc
committed
Avoid fetching one past the end of translate()'s "to" parameter.
This is usually harmless, but if you were very unlucky it could
provoke a segfault due to the "to" string being right up against
the end of memory. Found via valgrind testing (so we might've
found it earlier, except that our regression tests lacked any
exercise of translate()'s deletion feature).
Fix by switching the order of the test-for-end-of-string and
advance-pointer steps. While here, compute "to_ptr + tolen"
just once. (Smarter compilers might figure that out for
themselves, but let's just make sure.)
Report and fix by Daniil Anisimov, in bug #17816.
Discussion: https://postgr.es/m/17816-70f3d2764e88a108@postgresql.org1 parent 6095069 commit d7056bc
File tree
3 files changed
+14
-5
lines changed- src
- backend/utils/adt
- test/regress
- expected
- sql
3 files changed
+14
-5
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
801 | 801 | | |
802 | 802 | | |
803 | 803 | | |
804 | | - | |
| 804 | + | |
| 805 | + | |
805 | 806 | | |
806 | 807 | | |
807 | 808 | | |
| |||
823 | 824 | | |
824 | 825 | | |
825 | 826 | | |
| 827 | + | |
826 | 828 | | |
827 | 829 | | |
828 | 830 | | |
| |||
857 | 859 | | |
858 | 860 | | |
859 | 861 | | |
860 | | - | |
| 862 | + | |
861 | 863 | | |
862 | 864 | | |
863 | 865 | | |
864 | 866 | | |
865 | | - | |
866 | | - | |
| 867 | + | |
867 | 868 | | |
| 869 | + | |
868 | 870 | | |
869 | | - | |
| 871 | + | |
870 | 872 | | |
871 | 873 | | |
872 | 874 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2443 | 2443 | | |
2444 | 2444 | | |
2445 | 2445 | | |
| 2446 | + | |
| 2447 | + | |
| 2448 | + | |
| 2449 | + | |
| 2450 | + | |
| 2451 | + | |
2446 | 2452 | | |
2447 | 2453 | | |
2448 | 2454 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
787 | 787 | | |
788 | 788 | | |
789 | 789 | | |
| 790 | + | |
790 | 791 | | |
791 | 792 | | |
792 | 793 | | |
| |||
0 commit comments