diff --git a/lib/gssapi/context_time.c b/lib/gssapi/context_time.c index d133261b7..36c6e8ff3 100644 --- a/lib/gssapi/context_time.c +++ b/lib/gssapi/context_time.c @@ -41,19 +41,11 @@ OM_uint32 gss_context_time OM_uint32 * time_rec ) { - OM_uint32 lifetime; - OM_uint32 ret; krb5_error_code kret; krb5_timestamp timeret; GSSAPI_KRB5_INIT (); - ret = gss_inquire_context(minor_status, context_handle, - NULL, NULL, &lifetime, NULL, NULL, NULL, NULL); - if (ret) { - return ret; - } - kret = krb5_timeofday(gssapi_krb5_context, &timeret); if (kret) { *minor_status = kret; @@ -61,7 +53,13 @@ OM_uint32 gss_context_time return GSS_S_FAILURE; } - *time_rec = lifetime - timeret; *minor_status = 0; + + if (context_handle->lifetime < timeret) { + *time_rec = 0; + return GSS_S_CONTEXT_EXPIRED; + } + + *time_rec = context_handle->lifetime - timeret; return GSS_S_COMPLETE; } diff --git a/lib/gssapi/krb5/context_time.c b/lib/gssapi/krb5/context_time.c index d133261b7..36c6e8ff3 100644 --- a/lib/gssapi/krb5/context_time.c +++ b/lib/gssapi/krb5/context_time.c @@ -41,19 +41,11 @@ OM_uint32 gss_context_time OM_uint32 * time_rec ) { - OM_uint32 lifetime; - OM_uint32 ret; krb5_error_code kret; krb5_timestamp timeret; GSSAPI_KRB5_INIT (); - ret = gss_inquire_context(minor_status, context_handle, - NULL, NULL, &lifetime, NULL, NULL, NULL, NULL); - if (ret) { - return ret; - } - kret = krb5_timeofday(gssapi_krb5_context, &timeret); if (kret) { *minor_status = kret; @@ -61,7 +53,13 @@ OM_uint32 gss_context_time return GSS_S_FAILURE; } - *time_rec = lifetime - timeret; *minor_status = 0; + + if (context_handle->lifetime < timeret) { + *time_rec = 0; + return GSS_S_CONTEXT_EXPIRED; + } + + *time_rec = context_handle->lifetime - timeret; return GSS_S_COMPLETE; }