Skip to content

Commit

Permalink
Increase length of line read to handle larger AWS tokens. (#278)
Browse files Browse the repository at this point in the history
In the wild I've found tokens of length 1044 coming back from EC2
instance metadata; mapcache will fail to parse these.  This change
doubles the size.

Note that AWS says "The size of the security token that AWS STS API
operations return is not fixed. We strongly recommend that you make no
assumptions about the maximum size.", see
https://docs.aws.amazon.com/STS/latest/APIReference/API_AssumeRole.html#API_AssumeRole_ResponseElements
  • Loading branch information
youngpm authored Jan 14, 2022
1 parent ecf59e4 commit 8b4d277
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions lib/cache_rest.c
Original file line number Diff line number Diff line change
Expand Up @@ -868,16 +868,16 @@ static void _mapcache_cache_s3_headers_add(mapcache_context *ctx, const char* me
if((rv=apr_file_open(&f, s3->credentials_file,
APR_FOPEN_READ|APR_FOPEN_BUFFERED|APR_FOPEN_BINARY,APR_OS_DEFAULT,
ctx->pool)) == APR_SUCCESS) {
char line[1024];
if( (rv = apr_file_gets(line,1024,f))== APR_SUCCESS) {
char line[2048];
if( (rv = apr_file_gets(line,2048,f))== APR_SUCCESS) {
_remove_lineends(line);
aws_access_key_id = apr_pstrdup(ctx->pool,line);
}
if( (rv = apr_file_gets(line,1024,f))== APR_SUCCESS) {
if( (rv = apr_file_gets(line,2048,f))== APR_SUCCESS) {
_remove_lineends(line);
aws_secret_access_key = apr_pstrdup(ctx->pool,line);
}
if( (rv = apr_file_gets(line,1024,f))== APR_SUCCESS) {
if( (rv = apr_file_gets(line,2048,f))== APR_SUCCESS) {
_remove_lineends(line);
aws_security_token = apr_pstrdup(ctx->pool,line);
}
Expand Down

0 comments on commit 8b4d277

Please sign in to comment.