[OTR-dev] Active fingerprint context pointer possible issue

Ian Goldberg ian at cypherpunks.ca
Thu Nov 29 13:07:22 EST 2012


On Wed, Nov 28, 2012 at 01:41:19PM -0500, David Goulet wrote:
> So, what I do now is once I've found the right Fingerprint object (from
> the human representation), I iterate over all contexts of the
> fingerprint and check for an encrypted msgstate. Basically:
> 
>     for (context = fp->context; context != NULL; context = context->next) {
>         if (context->msgstate == OTRL_MSGSTATE_ENCRYPTED) {
> 		return 1;
>         }
>     }

I think that's not quite right.  That will iterate over *all* contexts
starting with the one you found, not all contexts with the same master.

I think you want:

     for (context = fp->context;
          context != NULL && context->m_context == fp->context;
	  context = context->next) {

But even that only checks whether *any* child of the same master is
encrypted, so you'd miss the case where another child of the same master
is ENCRYPTED, but with a different fp.  So perhaps:

     for (context = fp->context;
          context != NULL && context->m_context == fp->context;
	  context = context->next) {

              if (context->msgstate == OTRL_MSGSTATE_ENCRYPTED &&
		    context->active_fingerprint == fp) {
		return 1;
	      }
     }

   - Ian



More information about the OTR-dev mailing list