// TEST
sleep(1);
+ // UINT_MAX will cause api error, it is to big value
ret = security_server_set_pwd(TEST_PASSWORD, TEST_PASSWORD, 0, UINT_MAX);
+ RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_ERROR_BAD_REQUEST, "ret = " << ret);
+ sleep(1);
+ // calculate max applicable valid days that will not be rejected by ss
+ // ensure, that after conversion from days to seconds in ss there will be no uint overflow
+ unsigned int valid_days = ((UINT_MAX - time(NULL)) / 86400) - 1;
+ ret = security_server_set_pwd(TEST_PASSWORD, TEST_PASSWORD, 0, valid_days);
RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret);
}
int ret;
// Prepare environment
reset_security_server();
- ret = security_server_set_pwd(NULL, TEST_PASSWORD, 10, UINT_MAX);
+ // calculate max applicable valid days that will not be rejected by ss
+ // ensure, that after conversion from days to seconds in ss there will be no uint overflow
+ unsigned int valid_days = ((UINT_MAX - time(NULL)) / 86400) - 1;
+ ret = security_server_set_pwd(NULL, TEST_PASSWORD, 10, valid_days);
RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret);
// TESTS