diff options
| author | Alex Gaynor <alex.gaynor@gmail.com> | 2014-02-01 09:40:28 -0800 |
|---|---|---|
| committer | Alex Gaynor <alex.gaynor@gmail.com> | 2014-02-01 09:40:28 -0800 |
| commit | e4ec95d87da51c7dfd039e3925814d6c9a7380da (patch) | |
| tree | 1edd894c6a9616076f7e362df3d3d30db9a5d02e /cryptography | |
| parent | 390d38e264eaccff1cd285624146710fff5f8775 (diff) | |
| parent | 7581866c0c3a33698767c2b2adc2eee3bf525fe0 (diff) | |
| download | cryptography-e4ec95d87da51c7dfd039e3925814d6c9a7380da.tar.gz cryptography-e4ec95d87da51c7dfd039e3925814d6c9a7380da.tar.bz2 cryptography-e4ec95d87da51c7dfd039e3925814d6c9a7380da.zip | |
Merge pull request #541 from public/fix-466
Handle multiple errors on the stack
Diffstat (limited to 'cryptography')
| -rw-r--r-- | cryptography/hazmat/backends/openssl/backend.py | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/cryptography/hazmat/backends/openssl/backend.py b/cryptography/hazmat/backends/openssl/backend.py index cf931dab..e842f078 100644 --- a/cryptography/hazmat/backends/openssl/backend.py +++ b/cryptography/hazmat/backends/openssl/backend.py @@ -182,12 +182,20 @@ class Backend(object): if not code and isinstance(mode, GCM): raise InvalidTag assert code != 0 + + # consume any remaining errors on the stack + ignored_code = None + while ignored_code != 0: + ignored_code = self._lib.ERR_get_error() + + # raise the first error we found + return self._handle_error_code(code) + + def _handle_error_code(self, code): lib = self._lib.ERR_GET_LIB(code) func = self._lib.ERR_GET_FUNC(code) reason = self._lib.ERR_GET_REASON(code) - return self._handle_error_code(lib, func, reason) - def _handle_error_code(self, lib, func, reason): if lib == self._lib.ERR_LIB_EVP: if func == self._lib.EVP_F_EVP_ENCRYPTFINAL_EX: if reason == self._lib.EVP_R_DATA_NOT_MULTIPLE_OF_BLOCK_LENGTH: |
