[Pkg-privacy-commits] [libotr] 113/225: Record the time the last COMMIT was sent from a master context

Ximin Luo infinity0 at moszumanska.debian.org
Sat Aug 22 12:45:07 UTC 2015


This is an automated email from the git hooks/post-receive script.

infinity0 pushed a commit to branch master
in repository libotr.

commit 86e6cc35526ae99b3018534817b342e9c1ec7c48
Author: Ian Goldberg <iang at cs.uwaterloo.ca>
Date:   Sat Aug 25 16:31:42 2012 -0400

    Record the time the last COMMIT was sent from a master context
    
    This will be used to clear the committed key from the master context
    once we don't expect any more instances of our buddy to respond with a
    DHKEY message.
---
 src/auth.c    |  4 ++++
 src/auth.h    |  7 +++++++
 src/message.c | 11 ++++++++++-
 3 files changed, 21 insertions(+), 1 deletion(-)

diff --git a/src/auth.c b/src/auth.c
index 37ed20d..107dee8 100644
--- a/src/auth.c
+++ b/src/auth.c
@@ -59,6 +59,8 @@ void otrl_auth_dump(FILE *f, const OtrlAuthInfo *auth)
     fprintf(f, "\n    Proto version = %d\n", auth->protocol_version);
     fprintf(f, "\n    Lastauthmsg = %s\n",
 	auth->lastauthmsg ? auth->lastauthmsg : "(nil)");
+    fprintf(f, "\n    Commit sent time = %ld\n",
+	(long) auth->commit_sent_time);
 }
 
 #endif
@@ -90,6 +92,7 @@ void otrl_auth_new(struct context *context)
     memset(auth->secure_session_id, 0, 20);
     auth->secure_session_id_len = 0;
     auth->lastauthmsg = NULL;
+    auth->commit_sent_time = 0;
     auth->context = context;
 }
 
@@ -128,6 +131,7 @@ void otrl_auth_clear(OtrlAuthInfo *auth)
     auth->secure_session_id_len = 0;
     free(auth->lastauthmsg);
     auth->lastauthmsg = NULL;
+    auth->commit_sent_time = 0;
 }
 
 /*
diff --git a/src/auth.h b/src/auth.h
index b8437b3..0b9db54 100644
--- a/src/auth.h
+++ b/src/auth.h
@@ -22,6 +22,7 @@
 #define __AUTH_H__
 
 #include <gcrypt.h>
+#include <time.h>
 #include "dh.h"
 
 
@@ -75,6 +76,12 @@ typedef struct {
 					     (base-64 encoded) we sent,
 					     in case we need to
 					     retransmit it. */
+
+    time_t commit_sent_time;              /* The time we last sent the
+                                             lastauthmsg, if it was a
+					     COMMIT message, and this is
+					     a master context.  0
+					     otherwise. */
 } OtrlAuthInfo;
 
 #include "privkey-t.h"
diff --git a/src/message.c b/src/message.c
index 0b9c7ba..ea6b3b9 100644
--- a/src/message.c
+++ b/src/message.c
@@ -451,14 +451,23 @@ static gcry_error_t send_or_error_auth(const OtrlMessageAppOps *ops,
 	if (msg && *msg) {
 	    fragment_and_send(ops, opdata, context, msg,
 		    OTRL_FRAGMENT_SEND_ALL, NULL);
+	    time_t now = time(NULL);
 	    /* Update the "last sent" fields, unless this is a version 3
 	     * message typing to update the master context (as happens
 	     * when sending a v3 COMMIT message, for example). */
 	    if (context != context->m_context ||
 		    context->auth.protocol_version != 3) {
-		context->context_priv->lastsent = time(NULL);
+		context->context_priv->lastsent = now;
 		otrl_context_update_recent_child(context, 1);
 	    }
+
+	    /* If this is a master context, and we're sending a COMMIT
+	     * message, update the commit_sent_time timestamp, so we can
+	     * expire it. */
+	    if (context == context->m_context &&
+		context->auth.authstate == OTRL_AUTHSTATE_AWAITING_DHKEY) {
+		context->auth.commit_sent_time = now;
+	    }
 	}
     } else {
 	if (ops->handle_msg_event) {

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-privacy/packages/libotr.git



More information about the Pkg-privacy-commits mailing list