mirror of
https://github.com/python/cpython.git
synced 2025-08-03 08:34:29 +00:00
SF 952807: Unpickling pickled instances of subclasses of datetime.date,
datetime.datetime and datetime.time could yield insane objects. Thanks to Jiwon Seo for the fix. Bugfix candidate. I'll backport it to 2.3.
This commit is contained in:
parent
d348193ff2
commit
604c013ef2
3 changed files with 41 additions and 6 deletions
|
@ -2206,7 +2206,7 @@ date_new(PyTypeObject *type, PyObject *args, PyObject *kw)
|
|||
{
|
||||
PyDateTime_Date *me;
|
||||
|
||||
me = PyObject_New(PyDateTime_Date, type);
|
||||
me = (PyDateTime_Date *) (type->tp_alloc(type, 0));
|
||||
if (me != NULL) {
|
||||
char *pdata = PyString_AS_STRING(state);
|
||||
memcpy(me->data, pdata, _PyDateTime_DATE_DATASIZE);
|
||||
|
@ -3049,8 +3049,7 @@ time_new(PyTypeObject *type, PyObject *args, PyObject *kw)
|
|||
}
|
||||
}
|
||||
aware = (char)(tzinfo != Py_None);
|
||||
me = (PyDateTime_Time *) time_alloc(&PyDateTime_TimeType,
|
||||
aware);
|
||||
me = (PyDateTime_Time *) (type->tp_alloc(type, aware));
|
||||
if (me != NULL) {
|
||||
char *pdata = PyString_AS_STRING(state);
|
||||
|
||||
|
@ -3572,9 +3571,7 @@ datetime_new(PyTypeObject *type, PyObject *args, PyObject *kw)
|
|||
}
|
||||
}
|
||||
aware = (char)(tzinfo != Py_None);
|
||||
me = (PyDateTime_DateTime *) datetime_alloc(
|
||||
&PyDateTime_DateTimeType,
|
||||
aware);
|
||||
me = (PyDateTime_DateTime *) (type->tp_alloc(type , aware));
|
||||
if (me != NULL) {
|
||||
char *pdata = PyString_AS_STRING(state);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue