[Patches] Security Patch for Trashcan

Christian Tismer tismer@tismer.com
Sat, 25 Mar 2000 15:51:13 +0100


This is a patch to my recent patch concerning
destruction of deeply nested objects.

Reason:
There are rare cases where the thread state is undefined
while destructions can occour. This seems to happen in
the finalization phase only, but there are calls to
external finalizers like the LLNL extensions where
we cannot be sure if the error fetch/restore *might*
happen with undefined thread state.

Checkin-message:
Added "better safe than sorry" patch to the new
trashcan code in object.c, to ensure that tstate
is not touched when it might be undefined.

Diff:
*** //d/cvsroot/python/dist/src/objects/object.c	Mon Mar 13 19:00:26 2000
--- sp/objects/object.c	Sat Mar 25 16:37:50 2000
***************
*** 920,925 ****
--- 920,928 ----
  
    CT 2k0309
    modified to restore a possible error.
+ 
+   CT 2k0325
+   added better safe than sorry check for threadstate
  */
  
  int _PyTrash_delete_nesting = 0;
***************
*** 930,943 ****
  	PyObject *op;
  {
  	PyObject *error_type, *error_value, *error_traceback;
! 	PyErr_Fetch(&error_type, &error_value, &error_traceback);
  
  	if (!_PyTrash_delete_later)
  		_PyTrash_delete_later = PyList_New(0);
  	if (_PyTrash_delete_later)
  		PyList_Append(_PyTrash_delete_later, (PyObject *)op);
  
! 	PyErr_Restore(error_type, error_value, error_traceback);
  }
  
  void
--- 933,949 ----
  	PyObject *op;
  {
  	PyObject *error_type, *error_value, *error_traceback;
! 
! 	if (PyThreadState_GET() != NULL)
! 	    PyErr_Fetch(&error_type, &error_value, &error_traceback);
  
  	if (!_PyTrash_delete_later)
  		_PyTrash_delete_later = PyList_New(0);
  	if (_PyTrash_delete_later)
  		PyList_Append(_PyTrash_delete_later, (PyObject *)op);
  
! 	if (PyThreadState_GET() != NULL)
! 	    PyErr_Restore(error_type, error_value, error_traceback);
  }
  
  void
%%%%%%%%%%%%%%%%%%%%%%% end patch %%%%%%%%%%%%%%%%%%%%%%%%%%
Disclaimer:
I confirm that, to the best of my knowledge and belief, this
contribution is free of any claims of third parties under
copyright, patent or other rights or interests ("claims").  To
the extent that I have any such claims, I hereby grant to CNRI a
nonexclusive, irrevocable, royalty-free, worldwide license to
reproduce, distribute, perform and/or display publicly, prepare
derivative versions, and otherwise use this contribution as part
of the Python software and its related documentation, or any
derivative versions thereof, at no cost to CNRI or its licensed
users, and to authorize others to do so.

I acknowledge that CNRI may, at its sole discretion, decide
whether or not to incorporate this contribution in the Python
software and its related documentation.  I further grant CNRI
permission to use my name and other identifying information
provided to CNRI by me for use in connection with the Python
software and its related documentation.

-- 
Christian Tismer             :^)   <mailto:tismer@appliedbiometrics.com>
Applied Biometrics GmbH      :     Have a break! Take a ride on Python's
Kaunstr. 26                  :    *Starship* http://starship.python.net
14163 Berlin                 :     PGP key -> http://wwwkeys.pgp.net
PGP Fingerprint       E182 71C7 1A9D 66E9 9D15  D3CC D4D7 93E2 1FAE F6DF
     we're tired of banana software - shipped green, ripens at home

_______________________________________________
Patches mailing list
Patches@python.org
http://www.python.org/mailman/listinfo/patches

_______________________________________________
Patches mailing list
Patches@python.org
http://www.python.org/mailman/listinfo/patches