]> rtime.felk.cvut.cz Git - socketcan-devel.git/blobdiff - kernel/2.6/net/can/bcm.c
can: test size of struct sockaddr in sendmsg
[socketcan-devel.git] / kernel / 2.6 / net / can / bcm.c
index 9ffad22ae5d8d8eabd95e164929dfbd74caea2d3..a33218b9ed1155f5b7c1667617bb728c650e3390 100644 (file)
@@ -140,7 +140,7 @@ struct bcm_sock {
        struct list_head tx_ops;
        unsigned long dropped_usr_msgs;
        struct proc_dir_entry *bcm_proc_read;
-       char procname [20]; /* pointer printed in ASCII with \0 */
+       char procname [32]; /* inode number in decimal with \0 */
 };
 
 static inline struct bcm_sock *bcm_sk(const struct sock *sk)
@@ -1381,6 +1381,9 @@ static int bcm_sendmsg(struct kiocb *iocb, struct socket *sock,
                struct sockaddr_can *addr =
                        (struct sockaddr_can *)msg->msg_name;
 
+               if (msg->msg_namelen < sizeof(*addr))
+                       return -EINVAL;
+
                if (addr->can_family != AF_CAN)
                        return -EINVAL;
 
@@ -1648,7 +1651,7 @@ static int bcm_connect(struct socket *sock, struct sockaddr *uaddr, int len,
 
        if (proc_dir) {
                /* unique socket address as filename */
-               sprintf(bo->procname, "%p", sock);
+               sprintf(bo->procname, "%lu", sock_i_ino(sk));
 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,26)
                bo->bcm_proc_read = proc_create_data(bo->procname, 0644,
                                                     proc_dir,
@@ -1729,7 +1732,9 @@ static struct proto bcm_proto __read_mostly = {
 static struct can_proto bcm_can_proto __read_mostly = {
        .type       = SOCK_DGRAM,
        .protocol   = CAN_BCM,
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,33)
        .capability = -1,
+#endif
        .ops        = &bcm_ops,
        .prot       = &bcm_proto,
 };