[Ns-bugs] [Bug 35] New: The Packet::AddTrailer function tries to write past the end of the buffer

bugzilla-daemon@nsnam-www.ece.gatech.edu bugzilla-daemon at nsnam-www.ece.gatech.edu
Mon Jun 11 10:45:13 PDT 2007


http://www.nsnam.org/bugzilla/show_bug.cgi?id=35

           Summary: The Packet::AddTrailer function tries to write past the
                    end of the buffer
           Product: ns-3
           Version: unspecified
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Keywords: bug
          Severity: major
          Priority: P3
         Component: simulation core
        AssignedTo: ns-bugs at isi.edu
        ReportedBy: emmanuelle.laprise at bluekazoo.ca


I've included a copy of the function (at the end) for reference. It adds a
chuck of memory to the buffer so that it is big enough to serialize the
trailer, but then it sets the iterator to the end of the buffer instead of
"size of trailer" bytes before the end of the buffer. 

I think that the patch will be to add a line following:
Buffer::Iterator end = m_buffer.End ();

end -= size;

I will try to generate a patch and test it briefly.

Emmanuelle

template <typename T>
void
Packet::AddTrailer (T const &trailer)
{
  NS_ASSERT_MSG (dynamic_cast<Trailer const *> (&trailer) != 0,
                 "Must pass Trailer subclass to Packet::AddTrailer");
  uint32_t size = trailer.GetSize ();
  m_buffer.AddAtEnd (size);
  Buffer::Iterator end = m_buffer.End ();
  trailer.Serialize (end);
}


-- 
Configure bugmail: http://www.nsnam.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.


More information about the Ns-bugs mailing list