Bug 992 - Unusual (possibly incorrect assertion) in Packet::Deserialize
Unusual (possibly incorrect assertion) in Packet::Deserialize
Status: RESOLVED FIXED
Product: ns-3
Classification: Unclassified
Component: core
ns-3-dev
All All
: P5 minor
Assigned To: Mathieu Lacage
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2010-09-16 00:10 EDT by Quincy Tse
Modified: 2010-09-29 17:22 EDT (History)
2 users (show)

See Also:


Attachments
Proposed patch (1.39 KB, patch)
2010-09-16 00:13 EDT, Quincy Tse
Details | Diff
Proposed patch. (1.44 KB, patch)
2010-09-16 00:14 EDT, Quincy Tse
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Quincy Tse 2010-09-16 00:10:29 EDT
../src/common/packet.cc:738:3: error: comparison of unsigned
      expression >= 0 is always true [-Wtautological-compare]

Same warning was also triggered in lines 767 and 787.

In Packet::Deserialize, size is uint32_t, thus always >=0 (NS_ASSERT line does not detect the buffer overflow).

Maybe the NS_ASSERTs should be something like the following?

== NS_ASSERT (size >= nixSize);
== NS_ASSERT (size >= metaSize);
== NS_ASSERT (size >= bufSize);
Comment 1 Quincy Tse 2010-09-16 00:13:32 EDT
Created attachment 973 [details]
Proposed patch
Comment 2 Quincy Tse 2010-09-16 00:14:38 EDT
Created attachment 974 [details]
Proposed patch.
Comment 3 Josh Pelkey 2010-09-29 17:22:51 EDT
(In reply to comment #2)
> Created an attachment (id=974) [details]
> Proposed patch.

You are right, and the patch is right.  I have applied: changeset 6d5c1c19bdfe

Thanks.