OSEC

Neohapsis is currently accepting applications for employment. For more information, please visit our website www.neohapsis.com or email hr@neohapsis.com
 
Re: [Muscle] BUG in PKCS11 module p11x_slot.c (Doesn't manage more than one reader correctly)

From: Ludovic Rousseau (ludovic.rousseaufree.fr)
Date: Tue Feb 22 2005 - 15:34:13 CST


Le Monday 07 February 2005 à 21:51:26, Chris Osgood a écrit:
> Thanks, your patch looks good but I don't think you want to break out of
> the while loop as there could be multiple active sessions on the slot.
>
> I think the attached patch looks right... Or something similar.
>
> --
> // Chris

> --- p11x_slot.c_orig 2005-02-07 21:47:10.411418180 -0500
> +++ p11x_slot.c 2005-02-07 21:47:37.670620376 -0500
> -881,10 +881,14
>
> while (session_l)
> {
> - if (session_l->session.slotID == slotID)
> + if (session_l->session.slotID != slotID)
> + session_l = session_l->next;
> + else
> + {
> + P11_Session *next = session_l->next;
> session_FreeSession(session_l);
> -
> - session_l = st.sessions;
> + session_l = next;
> + }
> }
>
> object_FreeAllObjects(slotID, st.slots[slotID - 1].objects);

This function is already patched in the CVS version (commited 4 weeks
ago). The patch is:

Index: p11x_slot.c
===================================================================
RCS file: /cvsroot/muscleapps/PKCS11/src/p11x_slot.c,v
retrieving revision 1.31
retrieving revision 1.32
diff -u -p -r1.31 -r1.32
--- p11x_slot.c 28 Nov 2004 14:30:32 -0000 1.31
+++ p11x_slot.c 22 Jan 2005 16:05:39 -0000 1.32
-882,9 +882,12 CK_RV slot_DisconnectSlot(CK_ULONG slotI
         while (session_l)
         {
             if (session_l->session.slotID == slotID)
+ {
                 session_FreeSession(session_l);
-
- session_l = st.sessions;
+ session_l = st.sessions;
+ }
+ else
+ session_l = session_l->next;
         }
 
         object_FreeAllObjects(slotID, st.slots[slotID - 1].objects);

It looks similar to the patch you propose but since it is your code and
not mine could you confirm that this patch is also correct?

Thanks,

--
 Dr. Ludovic Rousseau Ludovic.Rousseaufree.fr
 -- Normaliser Unix c'est comme pasteuriser le camembert, L.R. --
_______________________________________________
Muscle mailing list
Musclelists.musclecard.com
http://lists.drizzle.com/mailman/listinfo/muscle