Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/db/sysdb_sudo.c
Original file line number Diff line number Diff line change
Expand Up @@ -674,7 +674,7 @@ static errno_t sysdb_sudo_get_refresh_time(struct sss_domain_info *domain,
goto done;
}

*value = ldb_msg_find_attr_as_int(res->msgs[0], attr_name, 0);
*value = (time_t)ldb_msg_find_attr_as_uint64(res->msgs[0], attr_name, 0);

ret = EOK;

Expand Down
6 changes: 3 additions & 3 deletions src/providers/krb5/krb5_child.c
Original file line number Diff line number Diff line change
Expand Up @@ -306,19 +306,19 @@ static void sss_krb5_expire_callback_func(krb5_context context, void *data,
{
int ret;
uint32_t *blob;
long exp_time;
long long exp_time;
struct krb5_req *kr = talloc_get_type(data, struct krb5_req);

if (password_expiration == 0) {
return;
}

exp_time = password_expiration - time(NULL);
exp_time = (long long)(uint32_t)password_expiration - (long long)time(NULL);
if (exp_time < 0 || exp_time > UINT32_MAX) {
DEBUG(SSSDBG_CRIT_FAILURE, "Time to expire out of range.\n");
return;
}
DEBUG(SSSDBG_TRACE_INTERNAL, "exp_time: [%ld]\n", exp_time);
DEBUG(SSSDBG_TRACE_INTERNAL, "exp_time: [%lld]\n", exp_time);

blob = talloc_array(kr->pd, uint32_t, 2);
if (blob == NULL) {
Expand Down
2 changes: 1 addition & 1 deletion src/providers/ldap/ldap_child.c
Original file line number Diff line number Diff line change
Expand Up @@ -775,7 +775,7 @@ static krb5_error_code ldap_child_get_tgt_sync(TALLOC_CTX *memctx,

krberr = 0;
*ccname_out = talloc_steal(memctx, ccname);
*expire_time_out = my_creds.times.endtime - kdc_time_offset;
*expire_time_out = (time_t)(uint32_t)my_creds.times.endtime - kdc_time_offset;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi,

I agree with the expansion to time_t but it adds signedness as well. So I wonder if it would be safer to say

*expire_time_out = (time_t)(uint32_t)my_creds.times.endtime - (uint32_t)kdc_time_offset;

to make sure the krb5_timestamp value is treated as unsigned?

bye,
Sumit


done:
krb5_get_init_creds_opt_free(context, options);
Expand Down
8 changes: 4 additions & 4 deletions src/responder/kcm/kcm_renew.c
Original file line number Diff line number Diff line change
Expand Up @@ -558,10 +558,10 @@ static errno_t kcm_creds_check_times(TALLOC_CTX *mem_ctx,
int ret;

memset(&tgtt, 0, sizeof(tgtt));
tgtt.authtime = creds->times.authtime;
tgtt.starttime = creds->times.starttime;
tgtt.endtime = creds->times.endtime;
tgtt.renew_till = creds->times.renew_till;
tgtt.authtime = (uint32_t)creds->times.authtime;
tgtt.starttime = (uint32_t)creds->times.starttime;
tgtt.endtime = (uint32_t)creds->times.endtime;
tgtt.renew_till = (uint32_t)creds->times.renew_till;

now = time(NULL);
/* Attempt renewal only after half of the ticket lifetime has exceeded */
Expand Down
Loading