GitHub user paultiplady opened a pull request:
https://github.com/apache/libcloud/pull/844
[LIBCLOUD-835] Fix caching of Google auth tokens
## Fix corruption bug in Google auth token caching
### Description
The `GoogleOAuth2Credential. _write_token_to_file()` method writes a copy
of the latest OAuth token to disk. Prior to this fix, the token was being
written to disk without truncating the file first, which is fine in the case
where the new token has the same number of characters (or more) as the old one.
However, in some situations Google OAuth returns a shorter token string, which
was causing the library to crash when loading the corrupted token.
### Status
Fixed, needs tests.
### Checklist (tick everything that applies)
- [x] [Code
linting](http://libcloud.readthedocs.org/en/latest/development.html#code-style-guide)
(required, can be done after the PR checks)
- [ ] Documentation
- [ ] [Tests](http://libcloud.readthedocs.org/en/latest/testing.html)
- [ ]
[ICLA](http://libcloud.readthedocs.org/en/latest/development.html#contributing-bigger-changes)
(required for bigger changes)
_write_token_to_file was not zeroing the file before writing
a new token, causing corruption.
FIXES: LIBCLOUD-835
You can merge this pull request into a Git repository by running:
$ git pull https://github.com/qwil/libcloud
LIBCLOUD-835_google-token-corruption
Alternatively you can review and apply these changes as the patch at:
https://github.com/apache/libcloud/pull/844.patch
To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:
This closes #844
----
commit 9d05463aa2faa4733ac0129c2797ee9d043e58f9
Author: Paul Tiplady <[email protected]>
Date: 2016-07-22T18:32:27Z
[LIBCLOUD-835] Fix caching of Google auth tokens
_write_token_to_file was not zeroing the file before writing
a new token, causing corruption.
FIXES: LIBCLOUD-835
----
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---