diff options
Diffstat (limited to 'net/x25/af_x25.c')
-rw-r--r-- | net/x25/af_x25.c | 24 |
1 files changed, 19 insertions, 5 deletions
diff --git a/net/x25/af_x25.c b/net/x25/af_x25.c index e3219e4cd044..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> |
@@ -512,15 +513,20 @@ static int x25_create(struct net *net, struct socket *sock, int protocol, | |||
512 | { | 513 | { |
513 | struct sock *sk; | 514 | struct sock *sk; |
514 | struct x25_sock *x25; | 515 | struct x25_sock *x25; |
515 | int rc = -ESOCKTNOSUPPORT; | 516 | int rc = -EAFNOSUPPORT; |
516 | 517 | ||
517 | if (!net_eq(net, &init_net)) | 518 | if (!net_eq(net, &init_net)) |
518 | return -EAFNOSUPPORT; | 519 | goto out; |
519 | 520 | ||
520 | if (sock->type != SOCK_SEQPACKET || protocol) | 521 | rc = -ESOCKTNOSUPPORT; |
522 | if (sock->type != SOCK_SEQPACKET) | ||
521 | goto out; | 523 | goto out; |
522 | 524 | ||
523 | rc = -ENOMEM; | 525 | rc = -EINVAL; |
526 | if (protocol) | ||
527 | goto out; | ||
528 | |||
529 | rc = -ENOBUFS; | ||
524 | if ((sk = x25_alloc_socket(net)) == NULL) | 530 | if ((sk = x25_alloc_socket(net)) == NULL) |
525 | goto out; | 531 | goto out; |
526 | 532 | ||
@@ -643,7 +649,7 @@ static int x25_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len) | |||
643 | { | 649 | { |
644 | struct sock *sk = sock->sk; | 650 | struct sock *sk = sock->sk; |
645 | struct sockaddr_x25 *addr = (struct sockaddr_x25 *)uaddr; | 651 | struct sockaddr_x25 *addr = (struct sockaddr_x25 *)uaddr; |
646 | int rc = 0; | 652 | int len, i, rc = 0; |
647 | 653 | ||
648 | lock_kernel(); | 654 | lock_kernel(); |
649 | if (!sock_flag(sk, SOCK_ZAPPED) || | 655 | if (!sock_flag(sk, SOCK_ZAPPED) || |
@@ -653,6 +659,14 @@ static int x25_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len) | |||
653 | goto out; | 659 | goto out; |
654 | } | 660 | } |
655 | 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 | |||
656 | x25_sk(sk)->source_addr = addr->sx25_addr; | 670 | x25_sk(sk)->source_addr = addr->sx25_addr; |
657 | x25_insert_socket(sk); | 671 | x25_insert_socket(sk); |
658 | sock_reset_flag(sk, SOCK_ZAPPED); | 672 | sock_reset_flag(sk, SOCK_ZAPPED); |