From mboxrd@z Thu Jan 1 00:00:00 1970 From: Chris Packham Date: Wed, 4 Jan 2017 13:36:26 +1300 Subject: [U-Boot] [PATCH v2 2/2] lib: net_utils: enforce '.' as octet separator in string_to_ip In-Reply-To: <20170104003626.4211-1-judge.packham@gmail.com> References: <20170104003626.4211-1-judge.packham@gmail.com> Message-ID: <20170104003626.4211-2-judge.packham@gmail.com> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de Ensure '.' is used to separate octets. If another character is seen reject the string outright and return 0.0.0.0. Signed-off-by: Chris Packham --- Changes in v2: - new END lib/net_utils.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/net_utils.c b/lib/net_utils.c index 8f81e7801033..d06be22849fb 100644 --- a/lib/net_utils.c +++ b/lib/net_utils.c @@ -28,6 +28,10 @@ struct in_addr string_to_ip(const char *s) addr.s_addr = 0; return addr; } + if (i != 3 && *e != '.') { + addr.s_addr = 0; + return addr; + } addr.s_addr <<= 8; addr.s_addr |= (val & 0xFF); if (s) { -- 2.11.0.24.ge6920cf