From e267b6a11366e57f693e23c6ce8d7034476c888d Mon Sep 17 00:00:00 2001 From: Jeffrey Altman Date: Fri, 24 Aug 2007 14:33:09 +0000 Subject: [PATCH] NIM: Cannot cancel timers which have inserted a WM_TIMER message into the queue The credentials view in Network Identity Manager displays several user interface elements that need to be updated periodically such as any fields that denote the time remaining for a credential or an identity, or an icon and coloring used to indicate the expiration state. When the display rows are computed, the credentials view creates a set of timers that reference each row that times out when that row needs to be redrawn. Since the rows change when switching views or when the outline is recomputed, all the timers are canceled and re-scheduled. However, a race conditions exists where the timer times-out before it is canceled, in which case a WM_TIMER message is placed in the credential window's message queue. Windows does not support canceling a timer that has already fired and has been placed on the message queue. By the time the WM_TIMER message is received by the window, the rows of the display would have been recomputed and the row that the message references may not be what it intended to reference. A spurious WM_TIMER message is harmless when it refers to a row corresponding to a credential. However, the existing code assumed that if a timer event is received that referred to an outline row, then that outline must be an expanded view of an identity, which is currently the only type of outline row that receives timers. This assumption does not always hold in the case of a spurious WM_TIMER message and may lead to the code attempting to use the outline data as a handle to an identity. The patch fixes the problem by checking if the row is actually an expanded view of an identity and ignoring the message if it is not. ticket: new component: windows git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@19857 dc483132-0cff-0310-8789-dd5450dbe970 --- src/windows/identity/ui/credwnd.c | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/src/windows/identity/ui/credwnd.c b/src/windows/identity/ui/credwnd.c index 62c69668c..0d3f17fe5 100644 --- a/src/windows/identity/ui/credwnd.c +++ b/src/windows/identity/ui/credwnd.c @@ -1239,11 +1239,21 @@ cw_timer_proc(HWND hwnd, FILETIME ft_now; o = (khui_credwnd_outline *) r->data; -#ifdef DEBUG - assert(r->flags & KHUI_CW_ROW_EXPVIEW); - assert(o->attr_id == KCDB_ATTR_ID); - assert(tbl->flags & KHUI_CW_TBL_EXPIDENT); -#endif + + /* we only handle timers for header rows if : + + 1. The table is displaying expanded identity information + 2. The row displaying an expanded view + 3. The relevant outline object is for an identity + + If these conditions aren't met, it is because we lost a + race killing this timer while switching modes. + */ + if (!(tbl->flags & KHUI_CW_TBL_EXPIDENT) || + !(r->flags & KHUI_CW_ROW_EXPVIEW) || + !(o->attr_id == KCDB_ATTR_ID)) + + return; nflags = cw_get_buf_exp_flags(tbl, (khm_handle) o->data); if ((o->flags & CW_EXPSTATE_MASK) != nflags) { -- 2.26.2