[Ns-developers] PacketBB Serialization Bug

Tom Wambold tom5760 at gmail.com
Thu Dec 17 09:07:37 PST 2009


Hello all:

I just found a small bug in the Serialize method of PbbAddressBlock, where it
does not set a flag (AHAS_SINGLE_PRE_LEN) correctly when there is only a single
address in the address block.  This prevents the address block from being
deserialized properly.

The attached patch (reproduced below) fixes the issue.  Could this be
merged before
release?  If this should go in the bug tracker first, please let me know.

Thanks!
-Tom Wambold

-----

diff -r 41cff0992d09 src/node/packetbb.cc
--- a/src/node/packetbb.cc
+++ b/src/node/packetbb.cc
@@ -2014,11 +2014,12 @@
 PbbAddressBlock::Serialize (Buffer::Iterator &start) const
 {
   start.WriteU8 (AddressSize ());
+  Buffer::Iterator bufref = start;
+  uint8_t flags = 0;
+  start.Next ();

   if (AddressSize () == 1)
     {
-      start.WriteU8 (0);
-
       uint8_t buf[GetAddressLength ()];
       SerializeAddress (buf, AddressBegin ());
       start.Write (buf, GetAddressLength ());
@@ -2026,14 +2027,12 @@
       if (PrefixSize () == 1)
         {
           start.WriteU8 (PrefixFront ());
+          flags |= AHAS_SINGLE_PRE_LEN;
         }
+      bufref.WriteU8 (flags);
     }
   else if (AddressSize () > 0)
     {
-      Buffer::Iterator bufref = start;
-      uint8_t flags = 0;
-      start.Next ();
-
       uint8_t head[GetAddressLength ()];
       uint8_t tail[GetAddressLength ()];
       uint8_t headlen = 0;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: packetbb-fix-serialize-address-blocks
Type: application/octet-stream
Size: 934 bytes
Desc: not available
Url : http://mailman.isi.edu/pipermail/ns-developers/attachments/20091217/33f572d5/packetbb-fix-serialize-address-blocks.obj


More information about the Ns-developers mailing list