]> git.ipfire.org Git - thirdparty/krb5.git/commitdiff
Fix GSS krb5 initial sequence number gap handling
authorTomas Kuthan <tkuthan@gmail.com>
Thu, 6 Mar 2014 12:05:24 +0000 (13:05 +0100)
committerGreg Hudson <ghudson@mit.edu>
Tue, 18 Mar 2014 15:55:39 +0000 (11:55 -0400)
Since #2040, the dummy queue element inserted by g_order_init no
longer compares less than the initial sequence number, so we fail when
the first few sequence numbers are received out of order.  Properly
detect when a sequence number fits between the dummy element and the
first real queue element.

[ghudson@mit.edu: rewrote commit message]

ticket: 7872
target_version: 1.12.2
tags: pullup

src/lib/gssapi/generic/util_ordering.c

index 9a1ce8966ac977299ae21bf31cdaaa0f9cb985a1..22c6be2e3743d45200f29ea3f54814dde7a92b22 100644 (file)
@@ -195,6 +195,21 @@ g_order_check(void **vqueue, uint64_t seqnum)
                     return(GSS_S_UNSEQ_TOKEN);
             }
         }
+        /*
+         * Exception: if first token arrived out-of-order.
+         * In that case first two elements in queue are 0xFFFFFFFF and some k,
+         * where k > seqnum. We need to insert seqnum before k.
+         * We check this after the for-loop, because this should be rare.
+         */
+        if ((QELEM(q, q->start) == (((uint64_t)0 - 1) & q->mask)) &&
+            ((QELEM(q, q->start + 1) > seqnum))) {
+                queue_insert(q, q->start, seqnum);
+                if (q->do_replay && !q->do_sequence)
+                    return(GSS_S_COMPLETE);
+                else
+                    return(GSS_S_UNSEQ_TOKEN);
+
+        }
     }
 
     /* this should never happen */