[U-Boot] [PATCH v2 2/2] lib: net_utils: enforce '.' as octet separator in string_to_ip

Chris Packham judge.packham at gmail.com
Thu Jan 5 09:17:03 CET 2017


On Wed, Jan 4, 2017 at 11:09 PM, Wolfgang Denk <wd at denx.de> wrote:
> Dear Chris Packham,
>
> In message <20170104003626.4211-2-judge.packham at gmail.com> you wrote:
>> Ensure '.' is used to separate octets. If another character is seen
>> reject the string outright and return 0.0.0.0.
>
> What is this good for?
>
> The old code was forgiving and would accept 192,168,1,2 as well.

Technically you can't enter that. The env_flags.c code prevents that
from being added to environment variables that have been tagged as ip
addresses. These patches are pushing the logic down a bit further. The
code handling env_flags_vartype_ipaddr could be updated to use
string_to_ip instead.

> Do we need to be so strict here - at the cost of added code size?
>
> Also, at least crtitical parts of the network code (NFS, TFTP) do not
> check the return value of string_to_ip() - so what is the benefit of
> this change?
>

The reasoning behind this change is to prepare for parsing ipv6
addresses, which can contain ipv4 format addresses provided they are
at the end.

e.g. This is a valid ipv6 address "::ffff:192.168.1.1" and so is
"::ffff:0192:0168:0001:0001" but the former triggers the ipv4 mapping
logic.


More information about the U-Boot mailing list