Bug 2620 - Buffer::Iterator::ReadNtohU16 and ReadNtohU32 are inconsistent with other Read functions.
Buffer::Iterator::ReadNtohU16 and ReadNtohU32 are inconsistent with other Rea...
Status: PATCH WANTED
Product: ns-3
Classification: Unclassified
Component: network
ns-3-dev
All All
: P3 normal
Assigned To: ns-bugs
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2017-01-16 07:07 EST by debug.ito
Modified: 2018-01-04 16:07 EST (History)
1 user (show)

See Also:


Attachments
Test the behavior of Read functions. (1.90 KB, text/x-c++src)
2017-01-16 07:07 EST, debug.ito
Details

Note You need to log in before you can comment on or make changes to this bug.
Description debug.ito 2017-01-16 07:07:09 EST
Created attachment 2748 [details]
Test the behavior of Read functions.

Most of Buffer::Iterator's Read* member functions crash the application by an assertion error if the buffer's remaining size is smaller than the expected size. However, ReadNtoU16 and ReadNtoU32 sometimes do NOT crash the application. Instead they return some values as if they succeeded. This inconsistent behavior may hide the error, causing a bug that is tricky to track down.

This inconsistent behavior is demonstrated in the attached test file. Because I was not sure how to check a code failing an assertion, you have to enable lines with "it crashes" comments manually and see how it crashes the test. The point is, while other Read functions crash the application, ReadNtohU16 and ReadNtoh32 do not.

I think the cause of this bug lies in the "by-pass" code of these two functions for better performance.