Bug 992

Summary: Unusual (possibly incorrect assertion) in Packet::Deserialize
Product: ns-3 Reporter: Quincy Tse <quincy.tse>
Component: coreAssignee: Mathieu Lacage <mathieu.lacage>
Status: RESOLVED FIXED    
Severity: minor CC: jpelkey, ns-bugs
Priority: P5    
Version: ns-3-dev   
Hardware: All   
OS: All   
Attachments: Proposed patch
Proposed patch.

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.