Skip to content

Commit

Permalink
Increase line buffer size when reading S3 credentials file
Browse files Browse the repository at this point in the history
  • Loading branch information
peetw committed May 10, 2024
1 parent d9e53aa commit 33d9549
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions lib/cache_rest.c
Original file line number Diff line number Diff line change
Expand Up @@ -869,16 +869,18 @@ 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[2048];
if( (rv = apr_file_gets(line,2048,f))== APR_SUCCESS) {
// Line length buffer increased to handle longer session tokens; see:
// https://docs.aws.amazon.com/IAM/latest/UserGuide/id_credentials_temp_request.html
char line[4096];
if( (rv = apr_file_gets(line,4096,f))== APR_SUCCESS) {
_remove_lineends(line);
aws_access_key_id = apr_pstrdup(ctx->pool,line);
}
if( (rv = apr_file_gets(line,2048,f))== APR_SUCCESS) {
if( (rv = apr_file_gets(line,4096,f))== APR_SUCCESS) {
_remove_lineends(line);
aws_secret_access_key = apr_pstrdup(ctx->pool,line);
}
if( (rv = apr_file_gets(line,2048,f))== APR_SUCCESS) {
if( (rv = apr_file_gets(line,4096,f))== APR_SUCCESS) {
_remove_lineends(line);
aws_security_token = apr_pstrdup(ctx->pool,line);
}
Expand Down

0 comments on commit 33d9549

Please sign in to comment.