Skip to content

Commit 8b4d277

Browse files
authored
Increase length of line read to handle larger AWS tokens. (#278)
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
1 parent ecf59e4 commit 8b4d277

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

lib/cache_rest.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -868,16 +868,16 @@ static void _mapcache_cache_s3_headers_add(mapcache_context *ctx, const char* me
868868
if((rv=apr_file_open(&f, s3->credentials_file,
869869
APR_FOPEN_READ|APR_FOPEN_BUFFERED|APR_FOPEN_BINARY,APR_OS_DEFAULT,
870870
ctx->pool)) == APR_SUCCESS) {
871-
char line[1024];
872-
if( (rv = apr_file_gets(line,1024,f))== APR_SUCCESS) {
871+
char line[2048];
872+
if( (rv = apr_file_gets(line,2048,f))== APR_SUCCESS) {
873873
_remove_lineends(line);
874874
aws_access_key_id = apr_pstrdup(ctx->pool,line);
875875
}
876-
if( (rv = apr_file_gets(line,1024,f))== APR_SUCCESS) {
876+
if( (rv = apr_file_gets(line,2048,f))== APR_SUCCESS) {
877877
_remove_lineends(line);
878878
aws_secret_access_key = apr_pstrdup(ctx->pool,line);
879879
}
880-
if( (rv = apr_file_gets(line,1024,f))== APR_SUCCESS) {
880+
if( (rv = apr_file_gets(line,2048,f))== APR_SUCCESS) {
881881
_remove_lineends(line);
882882
aws_security_token = apr_pstrdup(ctx->pool,line);
883883
}

0 commit comments

Comments
 (0)