in source/sigv4.c [771:842]
static SigV4Status_t validateDateTime( const SigV4DateTime_t * pDateElements )
{
SigV4Status_t returnStatus = SigV4Success;
const int32_t daysPerMonth[] = MONTH_DAYS;
assert( pDateElements != NULL );
if( pDateElements->tm_year < YEAR_MIN )
{
LogError( ( "Invalid 'year' value parsed from date string. "
"Expected an integer %ld or greater, received: %ld",
( long int ) YEAR_MIN,
( long int ) pDateElements->tm_year ) );
returnStatus = SigV4ISOFormattingError;
}
if( ( pDateElements->tm_mon < 1 ) || ( pDateElements->tm_mon > 12 ) )
{
LogError( ( "Invalid 'month' value parsed from date string. "
"Expected an integer between 1 and 12, received: %ld",
( long int ) pDateElements->tm_mon ) );
returnStatus = SigV4ISOFormattingError;
}
/* Ensure that the day of the month is valid for the relevant month. */
if( ( returnStatus != SigV4ISOFormattingError ) &&
( ( pDateElements->tm_mday < 1 ) ||
( pDateElements->tm_mday > daysPerMonth[ pDateElements->tm_mon - 1 ] ) ) )
{
/* Check if the date is a valid leap year day. */
returnStatus = checkLeap( pDateElements );
if( returnStatus == SigV4ISOFormattingError )
{
LogError( ( "Invalid 'day' value parsed from date string. "
"Expected an integer between 1 and %ld, received: %ld",
( long int ) daysPerMonth[ pDateElements->tm_mon - 1 ],
( long int ) pDateElements->tm_mday ) );
}
}
/* SigV4DateTime_t values are asserted to be non-negative before they are
* assigned in function addToDate(). Therefore, we only verify logical upper
* bounds for the following values. */
if( pDateElements->tm_hour > 23 )
{
LogError( ( "Invalid 'hour' value parsed from date string. "
"Expected an integer between 0 and 23, received: %ld",
( long int ) pDateElements->tm_hour ) );
returnStatus = SigV4ISOFormattingError;
}
if( pDateElements->tm_min > 59 )
{
LogError( ( "Invalid 'minute' value parsed from date string. "
"Expected an integer between 0 and 59, received: %ld",
( long int ) pDateElements->tm_min ) );
returnStatus = SigV4ISOFormattingError;
}
/* An upper limit of 60 accounts for the occasional leap second UTC
* adjustment. */
if( pDateElements->tm_sec > 60 )
{
LogError( ( "Invalid 'second' value parsed from date string. "
"Expected an integer between 0 and 60, received: %ld",
( long int ) pDateElements->tm_sec ) );
returnStatus = SigV4ISOFormattingError;
}
return returnStatus;
}