Skip to content

Commit

Permalink
net: add bound checking in net_addr_pton()
Browse files Browse the repository at this point in the history
The net_addr_pton() did not check the number of ":" characters properly.
For example with following net-shell input
net ping fe80::210:2030:9b:d48efe80::210:2030:9b:d48e
the kernel panics.

Signed-off-by: Walter Xie <[email protected]>
  • Loading branch information
walter-xie authored and jukkar committed Jul 5, 2018
1 parent 3712578 commit 354c50e
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions subsys/net/ip/utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -344,6 +344,10 @@ int net_addr_pton(sa_family_t family, const char *src,
if (*tmp == ':') {
i--;
}

if (i < 0) {
return -EINVAL;
}
} while (tmp-- != src);

src++;
Expand Down

0 comments on commit 354c50e

Please sign in to comment.