Commit 4c82b23
committed
Trent Mick <[email protected]>:
This patch fixes possible overflow in the use of
PyOS_GetLastModificationTime in getmtime.c and Python/import.c.
Currently PyOS_GetLastModificationTime returns a C long. This can
overflow on Win64 where sizeof(time_t) > sizeof(long). Besides it
should logically return a time_t anyway (this patch changes this).
As well, import.c uses PyOS_GetLastModificationTime for .pyc
timestamping. There has been recent discussion about the .pyc header
format on python-dev. This patch adds oveflow checking to import.c so
that an exception will be raised if the modification time
overflows. There are a few other minor 64-bit readiness changes made
to the module as well:
- size_t instead of int or long for function-local buffer and string
length variables
- one buffer overflow check was added (raises an exception on possible
overflow, this overflow chance exists on 32-bit platforms as well), no
other possible buffer overflows existed (from my analysis anyway)
Closes SourceForge patch #100509.1 parent 4358b2c commit 4c82b23
2 files changed
Lines changed: 33 additions & 14 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
33 | 33 | | |
34 | 34 | | |
35 | 35 | | |
| 36 | + | |
36 | 37 | | |
37 | 38 | | |
38 | 39 | | |
39 | 40 | | |
40 | 41 | | |
41 | 42 | | |
42 | | - | |
| 43 | + | |
43 | 44 | | |
44 | 45 | | |
45 | 46 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
74 | 74 | | |
75 | 75 | | |
76 | 76 | | |
77 | | - | |
| 77 | + | |
78 | 78 | | |
79 | 79 | | |
80 | 80 | | |
| |||
549 | 549 | | |
550 | 550 | | |
551 | 551 | | |
552 | | - | |
| 552 | + | |
553 | 553 | | |
554 | | - | |
| 554 | + | |
555 | 555 | | |
556 | 556 | | |
557 | 557 | | |
| |||
732 | 732 | | |
733 | 733 | | |
734 | 734 | | |
735 | | - | |
| 735 | + | |
736 | 736 | | |
737 | 737 | | |
738 | 738 | | |
739 | 739 | | |
740 | 740 | | |
741 | 741 | | |
742 | 742 | | |
743 | | - | |
| 743 | + | |
| 744 | + | |
| 745 | + | |
| 746 | + | |
| 747 | + | |
| 748 | + | |
| 749 | + | |
| 750 | + | |
| 751 | + | |
| 752 | + | |
| 753 | + | |
| 754 | + | |
| 755 | + | |
| 756 | + | |
744 | 757 | | |
745 | 758 | | |
746 | 759 | | |
| |||
771 | 784 | | |
772 | 785 | | |
773 | 786 | | |
774 | | - | |
| 787 | + | |
775 | 788 | | |
776 | 789 | | |
777 | 790 | | |
| |||
869 | 882 | | |
870 | 883 | | |
871 | 884 | | |
872 | | - | |
| 885 | + | |
873 | 886 | | |
874 | 887 | | |
875 | | - | |
| 888 | + | |
| 889 | + | |
876 | 890 | | |
877 | 891 | | |
878 | 892 | | |
| |||
882 | 896 | | |
883 | 897 | | |
884 | 898 | | |
| 899 | + | |
| 900 | + | |
| 901 | + | |
| 902 | + | |
885 | 903 | | |
886 | 904 | | |
887 | 905 | | |
| |||
933 | 951 | | |
934 | 952 | | |
935 | 953 | | |
936 | | - | |
| 954 | + | |
937 | 955 | | |
938 | 956 | | |
939 | 957 | | |
| |||
1181 | 1199 | | |
1182 | 1200 | | |
1183 | 1201 | | |
1184 | | - | |
1185 | | - | |
| 1202 | + | |
| 1203 | + | |
1186 | 1204 | | |
1187 | 1205 | | |
1188 | 1206 | | |
| |||
1577 | 1595 | | |
1578 | 1596 | | |
1579 | 1597 | | |
1580 | | - | |
| 1598 | + | |
1581 | 1599 | | |
1582 | 1600 | | |
1583 | 1601 | | |
| |||
1612 | 1630 | | |
1613 | 1631 | | |
1614 | 1632 | | |
1615 | | - | |
| 1633 | + | |
1616 | 1634 | | |
1617 | 1635 | | |
1618 | 1636 | | |
| |||
0 commit comments