From fae8dacab5233c46f09e7d869afadaead2842609 Mon Sep 17 00:00:00 2001 From: Richard van der Hoff Date: Wed, 25 May 2016 15:44:39 +0100 Subject: [PATCH] Add a comment explaining Mark's latest fix --- src/megolm.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/megolm.c b/src/megolm.c index affd3cb..3395449 100644 --- a/src/megolm.c +++ b/src/megolm.c @@ -116,6 +116,11 @@ void megolm_advance_to(Megolm *megolm, uint32_t advance_to) { ((advance_to >> shift) - (megolm->counter >> shift)) & 0xff; if (steps == 0) { + /* deal with the edge case where megolm->counter is slightly larger + * than advance_to. This should only happen for R(0), and implies + * that advance_to has wrapped around and we need to advance R(0) + * 256 times. + */ if (advance_to < megolm->counter) { steps = 0x100; } else {