]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
mlx4_vnic: fix potential data corruption in sprintf
authorSaeed Mahameed <saeedm@mellanox.com>
Sun, 13 Apr 2014 08:58:36 +0000 (11:58 +0300)
committerMukesh Kacker <mukesh.kacker@oracle.com>
Tue, 7 Jul 2015 21:45:19 +0000 (14:45 -0700)
Signed-off-by: Saeed Mahameed <saeedm@mellanox.com>
(Ported from Mellanox OFED 2.4)

Signed-off-by: Mukesh Kacker <mukesh.kacker@oracle.com>
drivers/net/ethernet/mellanox/mlx4_vnic/vnic.h
drivers/net/ethernet/mellanox/mlx4_vnic/vnic_fip_discover.c

index 03c12e93d211ab41a2dbeeca9fc5813cc35cbe7f..afdb7b73c2d4889a61b83dba21eddc82fc3110db 100644 (file)
@@ -155,6 +155,7 @@ extern struct ib_sa_client vnic_sa_client;
 #define VNIC_SYSFS_FLEN                (VNIC_NAME_LEN * 2) /* SYSFS file name len, allow pre/suffix (32)*/
 #define VNIC_SYSFS_LLEN                64
 #define VNIC_VENDOR_LEN                8
+#define DISCOVER_NAME_LEN      (VNIC_DESC_LEN + 5) /* VNIC_DESC_LEN + pkey len */
 #define GID_LEN                        16
 #define GUID_LEN               8
 #define IPV4_LEN               4
@@ -934,7 +935,7 @@ struct pkt_rcv_list {
 };
 
 struct fip_discover {
-       char name[VNIC_NAME_LEN];
+       char name[DISCOVER_NAME_LEN];
        struct vnic_port *port;
        struct list_head discover_list;
        spinlock_t lock;
index 3b87a442663732f5fb9f485cb57a04d42aa3c090..86f5cc78ce8354025893fcfc9e5c9147be194bb9 100644 (file)
@@ -231,7 +231,8 @@ int fip_discover_init(struct vnic_port *port, struct fip_discover *discover,
                discover->pkey = pkey;
                INIT_LIST_HEAD(&discover->gw_list);
                init_rwsem(&discover->l_rwsem);
-               sprintf(discover->name, "%s_P%x", port->name, discover->pkey);
+               snprintf(discover->name, DISCOVER_NAME_LEN,
+                        "%s_P%x", port->name, discover->pkey);
        }
        INIT_LIST_HEAD(&discover->hadmin_cache);
        vnic_mcast_root_init(&discover->mcast_tree);