From: Denis Kirjanov <kda@linux-powerpc.org>
To: netdev@vger.kernel.org
Cc: Denis Kirjanov <kda@linux-powerpc.org>
Subject: [net-next v2] ipv4: inet_bind: check the addr_len first
Date: Tue, 2 Jun 2015 15:21:04 +0300 [thread overview]
Message-ID: <1433247664-7151-1-git-send-email-kda@linux-powerpc.org> (raw)
Perform the address length check first, before calling
the proto specific bind() function
Signed-off-by: Denis Kirjanov <kda@linux-powerpc.org>
v2: add the proper tag tp the subject
---
net/ipv4/af_inet.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/net/ipv4/af_inet.c b/net/ipv4/af_inet.c
index 6ad0f7a..333e2fa 100644
--- a/net/ipv4/af_inet.c
+++ b/net/ipv4/af_inet.c
@@ -426,14 +426,15 @@ int inet_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len)
int chk_addr_ret;
int err;
+ err = -EINVAL;
+ if (addr_len < sizeof(struct sockaddr_in))
+ goto out;
+
/* If the socket has its own bind function then use it. (RAW) */
if (sk->sk_prot->bind) {
err = sk->sk_prot->bind(sk, uaddr, addr_len);
goto out;
}
- err = -EINVAL;
- if (addr_len < sizeof(struct sockaddr_in))
- goto out;
if (addr->sin_family != AF_INET) {
/* Compatibility games : accept AF_UNSPEC (mapped to AF_INET)
--
1.7.10.4
next reply other threads:[~2015-06-02 12:22 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-06-02 12:21 Denis Kirjanov [this message]
2015-06-02 14:33 ` [net-next v2] ipv4: inet_bind: check the addr_len first Hannes Frederic Sowa
2015-06-02 15:13 ` Denis Kirjanov
2015-06-02 21:30 ` Hannes Frederic Sowa
2015-06-03 6:56 ` Denis Kirjanov
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=1433247664-7151-1-git-send-email-kda@linux-powerpc.org \
--to=kda@linux-powerpc.org \
--cc=netdev@vger.kernel.org \
/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;
as well as URLs for NNTP newsgroup(s).