Skip to content

Commit d2e775a

Browse files
peppelinuxc00kiemon5ter
authored andcommitted
Fix StatusResponse when return_addrs is not set
`return_addrs` is set to `None` by default in `StatusResponse.__init__()`. If it is not filled with a proper value then `self._verify()` will fail because it tries to iterate over a `None` object. This PR avoids this error, by setting the `return_addrs` to `[]`. ``` if self.asynchop: if ( self.response.destination and self.response.destination not in self.return_addrs ): logger.error("%s not in %s", self.response.destination, self.return_addrs) return None ``` Signed-off-by: Ivan Kanakarakis <[email protected]>
1 parent ca0696c commit d2e775a

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

src/saml2/response.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,7 @@ class StatusResponse(object):
255255
def __init__(self, sec_context, return_addrs=None, timeslack=0,
256256
request_id=0, asynchop=True, conv_info=None):
257257
self.sec = sec_context
258-
self.return_addrs = return_addrs
258+
self.return_addrs = return_addrs or []
259259

260260
self.timeslack = timeslack
261261
self.request_id = request_id
@@ -402,10 +402,11 @@ def _verify(self):
402402
raise RequestVersionTooHigh()
403403

404404
if self.asynchop:
405-
if self.response.destination and \
406-
self.response.destination not in self.return_addrs:
407-
logger.error("%s not in %s", self.response.destination,
408-
self.return_addrs)
405+
if (
406+
self.response.destination
407+
and self.response.destination not in self.return_addrs
408+
):
409+
logger.error("%s not in %s", self.response.destination, self.return_addrs)
409410
return None
410411

411412
valid = self.issue_instant_ok() and self.status_ok()

0 commit comments

Comments
 (0)