diff options
author | andrew hendry <andrew.hendry@gmail.com> | 2010-02-13 21:00:45 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2010-02-16 00:49:52 -0500 |
commit | a9288525d2aed806c1b8a785c226d4a9e6371650 (patch) | |
tree | 5de6722a6dfc60e603caa9631609d379b6547a1e /net/x25/af_x25.c | |
parent | b18e7a06857833d2c7c8c8457e5a3a7c3327f643 (diff) |
X25: Dont let x25_bind use addresses containing characters
Addresses should be all digits.
Stops x25_bind using addresses containing characters.
Signed-off-by: Andrew Hendry <andrew.hendry@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/x25/af_x25.c')
-rw-r--r-- | net/x25/af_x25.c | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/net/x25/af_x25.c b/net/x25/af_x25.c index 6c7104edec60..9796f3ed1edb 100644 --- a/net/x25/af_x25.c +++ b/net/x25/af_x25.c | |||
@@ -55,6 +55,7 @@ | |||
55 | #include <linux/notifier.h> | 55 | #include <linux/notifier.h> |
56 | #include <linux/init.h> | 56 | #include <linux/init.h> |
57 | #include <linux/compat.h> | 57 | #include <linux/compat.h> |
58 | #include <linux/ctype.h> | ||
58 | 59 | ||
59 | #include <net/x25.h> | 60 | #include <net/x25.h> |
60 | #include <net/compat.h> | 61 | #include <net/compat.h> |
@@ -648,7 +649,7 @@ static int x25_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len) | |||
648 | { | 649 | { |
649 | struct sock *sk = sock->sk; | 650 | struct sock *sk = sock->sk; |
650 | struct sockaddr_x25 *addr = (struct sockaddr_x25 *)uaddr; | 651 | struct sockaddr_x25 *addr = (struct sockaddr_x25 *)uaddr; |
651 | int rc = 0; | 652 | int len, i, rc = 0; |
652 | 653 | ||
653 | lock_kernel(); | 654 | lock_kernel(); |
654 | if (!sock_flag(sk, SOCK_ZAPPED) || | 655 | if (!sock_flag(sk, SOCK_ZAPPED) || |
@@ -658,6 +659,14 @@ static int x25_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len) | |||
658 | goto out; | 659 | goto out; |
659 | } | 660 | } |
660 | 661 | ||
662 | len = strlen(addr->sx25_addr.x25_addr); | ||
663 | for (i = 0; i < len; i++) { | ||
664 | if (!isdigit(addr->sx25_addr.x25_addr[i])) { | ||
665 | rc = -EINVAL; | ||
666 | goto out; | ||
667 | } | ||
668 | } | ||
669 | |||
661 | x25_sk(sk)->source_addr = addr->sx25_addr; | 670 | x25_sk(sk)->source_addr = addr->sx25_addr; |
662 | x25_insert_socket(sk); | 671 | x25_insert_socket(sk); |
663 | sock_reset_flag(sk, SOCK_ZAPPED); | 672 | sock_reset_flag(sk, SOCK_ZAPPED); |