Skip to content

Commit

Permalink
Fix off-by-one bug when calculating swift token length
Browse files Browse the repository at this point in the history
  • Loading branch information
alistairking committed Mar 5, 2019
1 parent 9441b56 commit 2fc4aa1
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions lib/swift-support/keystone.c
Original file line number Diff line number Diff line change
Expand Up @@ -85,15 +85,15 @@ static size_t auth_header_cb(char *buf, size_t size, size_t nmemb, void *data) {
keystone_auth_token_t *token = (keystone_auth_token_t *)data;
size_t buflen = size * nmemb;
char *p;
int chomplen = 0;
size_t chomplen = 0;
int token_len = 0;

if (buflen > strlen(TOKEN_HDR) &&
strncmp(buf, TOKEN_HDR, strlen(TOKEN_HDR)) == 0) {
// figure out how much trailing garbage there is (e.g., newline)
// apparently it is possible that there will be none
p = buf + buflen;
while (*p == '\0' || *p == '\n' || *p == '\r') {
p = buf + buflen - 1;
while ((chomplen < buflen) && (*p == '\0' || *p == '\n' || *p == '\r')) {
p--;
chomplen++;
}
Expand Down

0 comments on commit 2fc4aa1

Please sign in to comment.