diff --git a/CMake/Dependencies/libkvspic-CMakeLists.txt b/CMake/Dependencies/libkvspic-CMakeLists.txt index b72be4bcc..6ab35a2da 100644 --- a/CMake/Dependencies/libkvspic-CMakeLists.txt +++ b/CMake/Dependencies/libkvspic-CMakeLists.txt @@ -7,7 +7,7 @@ include(ExternalProject) # clone repo only ExternalProject_Add(libkvspic-download GIT_REPOSITORY https://github.com/awslabs/amazon-kinesis-video-streams-pic.git - GIT_TAG d08be2e16303507d21b4cb376aecda98271687ad + GIT_TAG 57637ea593f4b43c509413a44d993ed08d7f2616 SOURCE_DIR "${CMAKE_CURRENT_BINARY_DIR}/kvspic-src" BINARY_DIR "${CMAKE_CURRENT_BINARY_DIR}/kvspic-build" CMAKE_ARGS diff --git a/CMakeLists.txt b/CMakeLists.txt index 953e6adb2..d23b3cafa 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,7 +1,7 @@ cmake_minimum_required(VERSION 3.6.3) set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/CMake;${CMAKE_MODULE_PATH}") include(Utilities) -project(KinesisVideoProducerC VERSION 1.5.0 LANGUAGES C) +project(KinesisVideoProducerC VERSION 1.5.1 LANGUAGES C) include(GNUInstallDirs) diff --git a/src/source/Common/FileCredentialProvider.c b/src/source/Common/FileCredentialProvider.c index 3ef36d95a..e955d6af8 100644 --- a/src/source/Common/FileCredentialProvider.c +++ b/src/source/Common/FileCredentialProvider.c @@ -121,9 +121,9 @@ STATUS readFileCredentials(PFileCredentialProvider pFileCredentialProvider) CHK(pFileCredentialProvider != NULL && pFileCredentialProvider->credentialsFilepath != NULL, STATUS_NULL_ARG); - // Refresh the credentials by reading from the credentials file if needed + // Only refresh the credentials by reading from the credentials file if needed. + // If we already have credentials and they are not expiring soon, we return successfully here. currentTime = pFileCredentialProvider->getCurrentTimeFn(pFileCredentialProvider->customData); - CHK(pFileCredentialProvider->pAwsCredentials == NULL || currentTime + CREDENTIAL_FILE_READ_GRACE_PERIOD > pFileCredentialProvider->pAwsCredentials->expiration, retStatus); @@ -174,7 +174,10 @@ STATUS readFileCredentials(PFileCredentialProvider pFileCredentialProvider) sessionTokenLen = sessionToken == NULL ? 0 : (UINT32) STRNLEN(sessionToken, MAX_SESSION_TOKEN_LEN); if (expirationStr != NULL) { - convertTimestampToEpoch(expirationStr, currentTime / HUNDREDS_OF_NANOS_IN_A_SECOND, &expiration); + // It makes more sense for createDefaultCallbacksProviderWithFileAuth to fail if the credentials are expired + // than for it to succeed and let later service calls fail. Clients who cache credentials in a file will not + // see an error the first time they call createDefaultCallbacksProviderWithFileAuth without this check. + CHK_STATUS(convertTimestampToEpoch(expirationStr, currentTime / HUNDREDS_OF_NANOS_IN_A_SECOND, &expiration)); } else { expiration = currentTime + MAX_ENFORCED_TOKEN_EXPIRATION_DURATION; } diff --git a/src/source/Response.c b/src/source/Response.c index 765449fd0..9b0f8397e 100644 --- a/src/source/Response.c +++ b/src/source/Response.c @@ -548,7 +548,9 @@ SIZE_T postResponseWriteCallback(PCHAR pBuffer, SIZE_T size, SIZE_T numItems, PV pNewBuffer = (PCHAR) MEMALLOC(pCurlResponse->callInfo.responseDataLen + dataSize + SIZEOF(CHAR)); if (pNewBuffer != NULL) { // Copy forward the old - MEMCPY(pNewBuffer, pCurlResponse->callInfo.responseData, pCurlResponse->callInfo.responseDataLen); + if (pCurlResponse->callInfo.responseDataLen > 0) { + MEMCPY(pNewBuffer, pCurlResponse->callInfo.responseData, pCurlResponse->callInfo.responseDataLen); + } // Append the new data MEMCPY((PBYTE) pNewBuffer + pCurlResponse->callInfo.responseDataLen, pBuffer, dataSize); diff --git a/tst/AwsCredentialsTest.cpp b/tst/AwsCredentialsTest.cpp index 59fbb0819..4d7f82434 100644 --- a/tst/AwsCredentialsTest.cpp +++ b/tst/AwsCredentialsTest.cpp @@ -253,7 +253,7 @@ TEST_F(AwsCredentialsTest, TestFileCredentialsWriteWithSession) { UINT32 length = ARRAY_SIZE(fileContent); // Store the credentials in a file under the current dir - length = SNPRINTF(fileContent, length, "CREDENTIALS %s 1234567890 %s %s", mAccessKey, mSecretKey, mSessionToken); + length = SNPRINTF(fileContent, length, "CREDENTIALS %s 2200-01-01T00:00:00Z %s %s", mAccessKey, mSecretKey, mSessionToken); ASSERT_GT(ARRAY_SIZE(fileContent), length); ASSERT_EQ(STATUS_SUCCESS, writeFile(TEST_FILE_CREDENTIALS_FILE_PATH, FALSE, FALSE, (PBYTE) fileContent, length)); diff --git a/tst/FileLoggerFunctionalityTest.cpp b/tst/FileLoggerFunctionalityTest.cpp index 0e0894c25..3b2b8edbc 100644 --- a/tst/FileLoggerFunctionalityTest.cpp +++ b/tst/FileLoggerFunctionalityTest.cpp @@ -1,7 +1,7 @@ #include "ProducerTestFixture.h" -// length of time and log level string in log: "2019-11-09 19:11:16.xxxxxx VERBOSE " -#define TIMESTRING_OFFSET 35 +// length of time and log level string in log: "2019-11-09 19:11:16.xxx VERBOSE " +#define TIMESTRING_OFFSET 32 namespace com { namespace amazonaws { namespace kinesis { namespace video {