krb5: avoid time-difference overflow
Use krb5_time_abs() rather than subtracting time_t values before passing the result to labs(). On signed 32-bit time_t platforms, subtracting far-apart times can overflow before labs() sees the value.
This commit is contained in:
committed by
Nico Williams
parent
fdeb3e6e4e
commit
f609aae209
+2
-2
@@ -952,7 +952,7 @@ pa_enc_ts_validate(astgs_request_t r, const PA_DATA *pa)
|
||||
r->cname);
|
||||
goto out;
|
||||
}
|
||||
if (labs(kdc_time - p.patimestamp) > r->context->max_skew) {
|
||||
if (krb5_time_abs(kdc_time, p.patimestamp) > r->context->max_skew) {
|
||||
char client_time[100];
|
||||
|
||||
krb5_format_time(r->context, p.patimestamp,
|
||||
@@ -962,7 +962,7 @@ pa_enc_ts_validate(astgs_request_t r, const PA_DATA *pa)
|
||||
_kdc_r_log(r, 4, "Too large time skew, "
|
||||
"client time %s is out by %u > %u seconds -- %s",
|
||||
client_time,
|
||||
(unsigned)labs(kdc_time - p.patimestamp),
|
||||
(unsigned)krb5_time_abs(kdc_time, p.patimestamp),
|
||||
r->context->max_skew,
|
||||
r->cname);
|
||||
kdc_audit_setkv_number((kdc_request_t)r, KDC_REQUEST_KV_AUTH_EVENT,
|
||||
|
||||
+2
-2
@@ -432,7 +432,7 @@ pk_check_pkauthenticator_win2k(krb5_context context,
|
||||
krb5_timeofday (context, &now);
|
||||
|
||||
/* XXX cusec */
|
||||
if (a->ctime == 0 || labs(a->ctime - now) > context->max_skew) {
|
||||
if (a->ctime == 0 || krb5_time_abs(a->ctime, now) > context->max_skew) {
|
||||
krb5_clear_error_message(context);
|
||||
return KRB5KRB_AP_ERR_SKEW;
|
||||
}
|
||||
@@ -451,7 +451,7 @@ pk_check_pkauthenticator(krb5_context context,
|
||||
krb5_timeofday (context, &now);
|
||||
|
||||
/* XXX cusec */
|
||||
if (a->ctime == 0 || labs(a->ctime - now) > context->max_skew) {
|
||||
if (a->ctime == 0 || krb5_time_abs(a->ctime, now) > context->max_skew) {
|
||||
krb5_clear_error_message(context);
|
||||
return KRB5KRB_AP_ERR_SKEW;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user