in source/sigv4.c [755:826]
static SigV4Status_t validateDateTime( const SigV4DateTime_t * pDateElements )
{
SigV4Status_t returnStatus = SigV4Success;
const int32_t daysPerMonth[] = MONTH_DAYS;
assert( pDateElements != NULL );
if( pDateElements->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->year ) );
returnStatus = SigV4ISOFormattingError;
}
if( ( pDateElements->mon < 1 ) || ( pDateElements->mon > 12 ) )
{
LogError( ( "Invalid 'month' value parsed from date string. "
"Expected an integer between 1 and 12, received: %ld",
( long int ) pDateElements->mon ) );
returnStatus = SigV4ISOFormattingError;
}
/* Ensure that the day of the month is valid for the relevant month. */
if( ( returnStatus != SigV4ISOFormattingError ) &&
( ( pDateElements->mday < 1 ) ||
( pDateElements->mday > daysPerMonth[ pDateElements->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->mon - 1 ],
( long int ) pDateElements->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->hour > 23 )
{
LogError( ( "Invalid 'hour' value parsed from date string. "
"Expected an integer between 0 and 23, received: %ld",
( long int ) pDateElements->hour ) );
returnStatus = SigV4ISOFormattingError;
}
if( pDateElements->min > 59 )
{
LogError( ( "Invalid 'minute' value parsed from date string. "
"Expected an integer between 0 and 59, received: %ld",
( long int ) pDateElements->min ) );
returnStatus = SigV4ISOFormattingError;
}
/* An upper limit of 60 accounts for the occasional leap second UTC
* adjustment. */
if( pDateElements->sec > 60 )
{
LogError( ( "Invalid 'second' value parsed from date string. "
"Expected an integer between 0 and 60, received: %ld",
( long int ) pDateElements->sec ) );
returnStatus = SigV4ISOFormattingError;
}
return returnStatus;
}