reauthorize: Fix a number of bugs caught by Coverity

Closes #555

Reviewed-by: Patrick Uiterwijk <puiterwijk@redhat.com>