Bug 2176 - Building Ipv4 address from char* doesn't look reliable
Building Ipv4 address from char* doesn't look reliable
Status: RESOLVED FIXED
Product: ns-3
Classification: Unclassified
Component: internet
pre-release
PC Linux
: P5 normal
Assigned To: George Riley
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2015-09-04 19:17 UTC by Matthieu Coudron
Modified: 2015-11-07 17:48 UTC (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Matthieu Coudron 2015-09-04 19:17:13 UTC
I forgot a "." when building the string "10.2.0.0" (was doing "10.2.00") and then instead of failing ns3 builded the ip "0.10.2.0".

I think ns3 should either:
- fail in such a case (this is the class constructor)
- or change the API to allow for the conversion to fail and be checked.
Comment 1 Matthieu Coudron 2015-09-04 19:17:56 UTC
Tried to look for a test suite to add my test but could not find it thus the addition of a test suite for that would be nice too.
Comment 2 Tommaso Pecorella 2015-11-07 17:41:11 UTC
I don't think that we need a test case for this.
The constructor now fails with an assert in the following cases:
1) missing a dot (i.e., less than 3 dots),
2) leading dot in the string (e.g., ".1.1.1")
3) trailing dot in the string (e.g., "1.1.1.")

Pushed in changeset:   11754:b3aa90cf76b9
Comment 3 Tommaso Pecorella 2015-11-07 17:48:34 UTC
changeset:   11755:82d8459595ce

Forgot one last case: "1..1.1", as is, the user forgot one number in the middle. Forgetting 2 numbers (3 dots in a row) is included in this one.