variable referenced before assignment error in keystone.contrib.federation.idp._sign_assertion

Bug #1481274 reported by Roman Bogorodskiy
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
OpenStack Identity (keystone)
Fix Released
Medium
Roman Bogorodskiy

Bug Description

The _sign_assertion() function from keystone.contrib.federation.idp assigns file_path variable in the try block and then tries to clean up the file in the finally block.

However, if fileutils.write_to_tempfile call raises then file_path is not assigned that results in UnboundLocalError:

      File "keystone/contrib/federation/idp.py", line 437, in _sign_assertion
        os.remove(file_path)
    UnboundLocalError: local variable 'file_path' referenced before assignment

Tags: federation
Changed in keystone:
assignee: nobody → Roman Bogorodskiy (novel)
status: New → In Progress
Dolph Mathews (dolph)
tags: added: federation
Changed in keystone:
importance: Undecided → Medium
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to keystone (master)

Reviewed: https://review.openstack.org/208163
Committed: https://git.openstack.org/cgit/openstack/keystone/commit/?id=defa9eeb51dbe8c035df911b18ab58b41459be80
Submitter: Jenkins
Branch: master

commit defa9eeb51dbe8c035df911b18ab58b41459be80
Author: Roman Bogorodskiy <email address hidden>
Date: Sat Aug 1 18:55:29 2015 +0300

    Fix unbound error in federation _sign_assertion

    The _sign_assertion() function from keystone.contrib.federation.idp
    assigns file_path variable in the try block and then tries to clean
    up the file in the finally block.

    However, if fileutils.write_to_tempfile call raises then file_path
    is not assigned that results in UnboundLocalError.

    Fix it by explicitly set file_path to None before calling
    fileutils.write_to_tempfile.

    Closes-Bug: #1481274
    Change-Id: Ib835c0980c20ceb791f1bed314a94e63c9cba910

Changed in keystone:
status: In Progress → Fix Committed
Changed in keystone:
milestone: none → liberty-3
status: Fix Committed → Fix Released
Thierry Carrez (ttx)
Changed in keystone:
milestone: liberty-3 → 8.0.0
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.