git://ftp.safe.ca
/
safe
/
jmp
/
linux-2.6
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
x25: use limited socket backlog
[safe/jmp/linux-2.6]
/
net
/
x25
/
af_x25.c
diff --git
a/net/x25/af_x25.c
b/net/x25/af_x25.c
index
f327ef5
..
9796f3e
100644
(file)
--- a/
net/x25/af_x25.c
+++ b/
net/x25/af_x25.c
@@
-55,6
+55,7
@@
#include <linux/notifier.h>
#include <linux/init.h>
#include <linux/compat.h>
#include <linux/notifier.h>
#include <linux/init.h>
#include <linux/compat.h>
+#include <linux/ctype.h>
#include <net/x25.h>
#include <net/compat.h>
#include <net/x25.h>
#include <net/compat.h>
@@
-512,15
+513,20
@@
static int x25_create(struct net *net, struct socket *sock, int protocol,
{
struct sock *sk;
struct x25_sock *x25;
{
struct sock *sk;
struct x25_sock *x25;
- int rc = -E
SOCKT
NOSUPPORT;
+ int rc = -E
AF
NOSUPPORT;
if (!net_eq(net, &init_net))
if (!net_eq(net, &init_net))
-
return -EAFNOSUPPORT
;
+
goto out
;
- if (sock->type != SOCK_SEQPACKET || protocol)
+ rc = -ESOCKTNOSUPPORT;
+ if (sock->type != SOCK_SEQPACKET)
goto out;
goto out;
- rc = -ENOMEM;
+ rc = -EINVAL;
+ if (protocol)
+ goto out;
+
+ rc = -ENOBUFS;
if ((sk = x25_alloc_socket(net)) == NULL)
goto out;
if ((sk = x25_alloc_socket(net)) == NULL)
goto out;
@@
-643,7
+649,7
@@
static int x25_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len)
{
struct sock *sk = sock->sk;
struct sockaddr_x25 *addr = (struct sockaddr_x25 *)uaddr;
{
struct sock *sk = sock->sk;
struct sockaddr_x25 *addr = (struct sockaddr_x25 *)uaddr;
- int rc = 0;
+ int
len, i,
rc = 0;
lock_kernel();
if (!sock_flag(sk, SOCK_ZAPPED) ||
lock_kernel();
if (!sock_flag(sk, SOCK_ZAPPED) ||
@@
-653,6
+659,14
@@
static int x25_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len)
goto out;
}
goto out;
}
+ len = strlen(addr->sx25_addr.x25_addr);
+ for (i = 0; i < len; i++) {
+ if (!isdigit(addr->sx25_addr.x25_addr[i])) {
+ rc = -EINVAL;
+ goto out;
+ }
+ }
+
x25_sk(sk)->source_addr = addr->sx25_addr;
x25_insert_socket(sk);
sock_reset_flag(sk, SOCK_ZAPPED);
x25_sk(sk)->source_addr = addr->sx25_addr;
x25_insert_socket(sk);
sock_reset_flag(sk, SOCK_ZAPPED);
@@
-1721,18
+1735,31
@@
static int __init x25_init(void)
if (rc != 0)
goto out;
if (rc != 0)
goto out;
- sock_register(&x25_family_ops);
+ rc = sock_register(&x25_family_ops);
+ if (rc != 0)
+ goto out_proto;
dev_add_pack(&x25_packet_type);
dev_add_pack(&x25_packet_type);
- register_netdevice_notifier(&x25_dev_notifier);
+ rc = register_netdevice_notifier(&x25_dev_notifier);
+ if (rc != 0)
+ goto out_sock;
printk(KERN_INFO "X.25 for Linux Version 0.2\n");
x25_register_sysctl();
printk(KERN_INFO "X.25 for Linux Version 0.2\n");
x25_register_sysctl();
- x25_proc_init();
+ rc = x25_proc_init();
+ if (rc != 0)
+ goto out_dev;
out:
return rc;
out:
return rc;
+out_dev:
+ unregister_netdevice_notifier(&x25_dev_notifier);
+out_sock:
+ sock_unregister(AF_X25);
+out_proto:
+ proto_unregister(&x25_proto);
+ goto out;
}
module_init(x25_init);
}
module_init(x25_init);