#670 Intermittent access violation using win32cred.CredRead

v1.0 (example)
open
nobody
None
5
2014-06-03
2014-04-29
Dan Soeder
No

Issue is intermittent and may be difficult to reproduce.

Call win32cred.CredRead with a TargetName that does not exist. This will randomly cause Python to crash with an access violation.

I believe the root cause is that the variable "cred" in PyCredRead is not being initialized. If the call to CredRead fails it will not set cred to any value. Since cred is uninitialized there's a random chance the PyCredRead will call CredFree on an invalid address.

Initializing cred to NULL stopped the crash from occurring during my testing.

Discussion

  • I believe I've started encountering this issue reliably in the keyring project test suite.

    Running the test suite on Python 3.4, I get through many tests, then Python crashes here:

    keyring/tests/backends/test_Windows.py <- keyring\tests\test_backend.py:83: WinVaultKeyringTestCase.test_delete_not_present

    Running that test by itself, it will pass, but running it in the context of a full test suite run triggers the behavior, which re-inforces Dan's description implicating a prior call.

    Using pywin32-ctypes does not exhibit the same behavior.

     
  • Roger Upole
    Roger Upole
    2014-06-03

    Just committed a fix for this.