net: utils: Port parsing failure in net_ipaddr_parse()
If trying to parse a string like 192.0.2.2:80/foobar and setting the length to 12 which means to parse the IP address and port, the parsing failed because it used one extra character from the string. This issue was not present if the input string was terminated after the port number. Add a test case to catch this problem. Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
This commit is contained in:
parent
06c0b764cc
commit
5f3e6212af
2 changed files with 17 additions and 2 deletions
|
@ -532,6 +532,21 @@ ZTEST(test_utils_fn, test_addr_parse)
|
|||
},
|
||||
.verdict = true
|
||||
},
|
||||
{
|
||||
.address = "192.0.2.3:80/foobar",
|
||||
.len = sizeof("192.0.2.3:80") - 1,
|
||||
.result = {
|
||||
.sin_family = AF_INET,
|
||||
.sin_port = htons(80),
|
||||
.sin_addr = {
|
||||
.s4_addr[0] = 192,
|
||||
.s4_addr[1] = 0,
|
||||
.s4_addr[2] = 2,
|
||||
.s4_addr[3] = 3
|
||||
}
|
||||
},
|
||||
.verdict = true
|
||||
},
|
||||
{
|
||||
.address = "192.0.2.3/foobar",
|
||||
.len = sizeof("192.0.2.3/foobar") - 1,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue