commit 939e74d3d6b2913beeb2d2718bebaab3f033577b
Author: Andreas Schlick <schlick@lavabit.com>
Date: Tue Dec 18 17:55:24 2012 +0100
Copy lastmessage to the newly created context.
This fixes a case where the first user message
gets lost when OTRL_POLICY_REQUIRE_ENCRYPTION
policy is set because after establishing the
encryption lastmessage remains with the master
context and will not be resent.
[Slightly modified by Ian Goldberg]
diff --git a/src/message.c b/src/message.c
index 7c39529..6b842bc 100644
--- a/src/message.c
+++ b/src/message.c
@@ -1078,9 +1078,14 @@ int otrl_message_receiving(OtrlUserState us, const OtrlMessageAppOps *ops,
/* Copy information from m_context to the new instance context */
context->auth.protocol_version = 3;
context->protocol_version = 3;
-
- if (context_added) {
- context->msgstate = m_context->msgstate;
+ context->msgstate = m_context->msgstate;
+
+ if (m_context->context_priv->may_retransmit) {
+ gcry_free(context->context_priv->lastmessage);
+ context->context_priv->lastmessage = m_context->context_priv->lastmessage;
+ m_context->context_priv->lastmessage = NULL;
+ context->context_priv->may_retransmit = m_context->context_priv->may_retransmit;
+ m_context->context_priv->may_retransmit = 0;
}
if (msgtype == OTRL_MSGTYPE_DH_KEY) {