--- embedaddon/quagga/lib/stream.c	2012/02/21 17:26:12	1.1.1.1
+++ embedaddon/quagga/lib/stream.c	2013/07/21 23:54:39	1.1.1.3
@@ -52,7 +52,7 @@
  * using stream_put..._at() functions.
  */
 #define STREAM_WARN_OFFSETS(S) \
-  zlog_warn ("&(struct stream): %p, size: %lu, endp: %lu, getp: %lu\n", \
+  zlog_warn ("&(struct stream): %p, size: %lu, getp: %lu, endp: %lu\n", \
              (S), \
              (unsigned long) (S)->size, \
              (unsigned long) (S)->getp, \
@@ -214,6 +214,30 @@ stream_set_getp (struct stream *s, size_t pos)
   s->getp = pos;
 }
 
+void
+stream_set_endp (struct stream *s, size_t pos)
+{
+  STREAM_VERIFY_SANE(s);
+
+  if (!ENDP_VALID(s, pos))
+    {
+      STREAM_BOUND_WARN (s, "set endp");
+      return;
+    }
+
+  /*
+   * Make sure the current read pointer is not beyond the new endp.
+   */
+  if (s->getp > pos)
+    {
+      STREAM_BOUND_WARN(s, "set endp");
+      return;
+    }
+
+  s->endp = pos;
+  STREAM_VERIFY_SANE(s);
+}
+
 /* Forward pointer. */
 void
 stream_forward_getp (struct stream *s, size_t size)
@@ -934,9 +958,9 @@ stream_fifo_pop (struct stream_fifo *fifo)
 
       if (fifo->head == NULL)
 	fifo->tail = NULL;
-    }
 
-  fifo->count--;
+      fifo->count--;
+    }
 
   return s; 
 }