From: Chris Packham <judge.packham@gmail.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH v2 2/2] lib: net_utils: enforce '.' as octet separator in string_to_ip
Date: Wed, 4 Jan 2017 13:36:26 +1300 [thread overview]
Message-ID: <20170104003626.4211-2-judge.packham@gmail.com> (raw)
In-Reply-To: <20170104003626.4211-1-judge.packham@gmail.com>
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 <judge.packham@gmail.com>
---
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
next prev parent reply other threads:[~2017-01-04 0:36 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-12-19 22:01 [U-Boot] [PATCH] lib: net_utils: make string_to_ip stricter Chris Packham
2016-12-26 5:23 ` Simon Glass
2016-12-26 8:56 ` Chris Packham
2017-01-04 0:36 ` [U-Boot] [PATCH v2 1/2] " Chris Packham
2017-01-04 0:36 ` Chris Packham [this message]
2017-01-04 10:09 ` [U-Boot] [PATCH v2 2/2] lib: net_utils: enforce '.' as octet separator in string_to_ip Wolfgang Denk
2017-01-05 8:17 ` Chris Packham
2017-01-08 18:45 ` Wolfgang Denk
2017-01-09 8:21 ` Chris Packham
2017-01-15 18:30 ` [U-Boot] [U-Boot, v2, " Tom Rini
2017-01-04 10:04 ` [U-Boot] [PATCH v2 1/2] lib: net_utils: make string_to_ip stricter Wolfgang Denk
2017-01-05 7:58 ` Chris Packham
2017-01-15 18:30 ` [U-Boot] [U-Boot, v2, " Tom Rini
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20170104003626.4211-2-judge.packham@gmail.com \
--to=judge.packham@gmail.com \
--cc=u-boot@lists.denx.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox