Commit 91396556 authored by Ben Collins's avatar Ben Collins Committed by David S. Miller

[NET]: strncpy -> strlcpy conversions.

parent f913f1d9
......@@ -223,7 +223,7 @@ static int parse_qos(const char *buff, int len)
int value[5];
memset(&qos, 0, sizeof(struct atm_qos));
strncpy(cmd, buff, 3);
strlcpy(cmd, buff, sizeof(cmd));
if( strncmp(cmd,"add", 3) && strncmp(cmd,"del", 3))
return 0; /* not add or del */
......
......@@ -743,9 +743,8 @@ static int ax25_getsockopt(struct socket *sock, int level, int optname,
ax25_dev = ax25->ax25_dev;
if (ax25_dev != NULL && ax25_dev->dev != NULL) {
strncpy(devname, ax25_dev->dev->name, IFNAMSIZ);
length = min_t(unsigned int, strlen(ax25_dev->dev->name)+1, maxlen);
devname[length-1] = '\0';
strlcpy(devname, ax25_dev->dev->name, sizeof(devname));
length = strlen(devname) + 1;
} else {
*devname = '\0';
length = 1;
......
......@@ -84,7 +84,7 @@ static struct net_bridge *new_nb(const char *name)
memset(br, 0, sizeof(*br));
dev = &br->dev;
strncpy(dev->name, name, IFNAMSIZ);
strlcpy(dev->name, name, sizeof(dev->name));
dev->priv = br;
dev->priv_flags = IFF_EBRIDGE;
ether_setup(dev);
......
......@@ -949,7 +949,7 @@ static int arp_req_get(struct arpreq *r, struct net_device *dev)
r->arp_flags = arp_state_to_flags(neigh);
read_unlock_bh(&neigh->lock);
r->arp_ha.sa_family = dev->type;
strncpy(r->arp_dev, dev->name, sizeof(r->arp_dev));
strlcpy(r->arp_dev, dev->name, sizeof(r->arp_dev));
neigh_release(neigh);
err = 0;
}
......
......@@ -1363,16 +1363,15 @@ static int __init ip_auto_config_setup(char *addrs)
case 4:
if ((dp = strchr(ip, '.'))) {
*dp++ = '\0';
strncpy(system_utsname.domainname, dp, __NEW_UTS_LEN);
system_utsname.domainname[__NEW_UTS_LEN] = '\0';
strlcpy(system_utsname.domainname, dp,
sizeof(system_utsname.domainname));
}
strncpy(system_utsname.nodename, ip, __NEW_UTS_LEN);
system_utsname.nodename[__NEW_UTS_LEN] = '\0';
strlcpy(system_utsname.nodename, ip,
sizeof(system_utsname.nodename));
ic_host_name_set = 1;
break;
case 5:
strncpy(user_dev_name, ip, IFNAMSIZ);
user_dev_name[IFNAMSIZ-1] = '\0';
strlcpy(user_dev_name, ip, sizeof(user_dev_name));
break;
case 6:
ic_proto_name(ip);
......
......@@ -60,7 +60,7 @@ int ircomm_open_lsap(struct ircomm_cb *self)
notify.connect_indication = ircomm_lmp_connect_indication;
notify.disconnect_indication = ircomm_lmp_disconnect_indication;
notify.instance = self;
strncpy(notify.name, "IrCOMM", NOTIFY_MAX_NAME);
strlcpy(notify.name, "IrCOMM", sizeof(notify.name));
self->lsap = irlmp_open_lsap(LSAP_ANY, &notify, 0);
if (!self->lsap) {
......
......@@ -60,7 +60,7 @@ int ircomm_open_tsap(struct ircomm_cb *self)
notify.flow_indication = ircomm_ttp_flow_indication;
notify.disconnect_indication = ircomm_ttp_disconnect_indication;
notify.instance = self;
strncpy(notify.name, "IrCOMM", NOTIFY_MAX_NAME);
strlcpy(notify.name, "IrCOMM", sizeof(notify.name));
self->tsap = irttp_open_tsap(LSAP_ANY, DEFAULT_INITIAL_CREDIT,
&notify);
......
......@@ -205,7 +205,7 @@ static int ircomm_tty_startup(struct ircomm_tty_cb *self)
notify.disconnect_indication = ircomm_tty_disconnect_indication;
notify.connect_confirm = ircomm_tty_connect_confirm;
notify.connect_indication = ircomm_tty_connect_indication;
strncpy(notify.name, "ircomm_tty", NOTIFY_MAX_NAME);
strlcpy(notify.name, "ircomm_tty", sizeof(notify.name));
notify.instance = self;
if (!self->ircomm) {
......
......@@ -268,7 +268,7 @@ void irlan_client_open_ctrl_tsap(struct irlan_cb *self)
notify.connect_confirm = irlan_client_ctrl_connect_confirm;
notify.disconnect_indication = irlan_client_ctrl_disconnect_indication;
notify.instance = self;
strncpy(notify.name, "IrLAN ctrl (c)", NOTIFY_MAX_NAME);
strlcpy(notify.name, "IrLAN ctrl (c)", sizeof(notify.name));
tsap = irttp_open_tsap(LSAP_ANY, DEFAULT_INITIAL_CREDIT, &notify);
if (!tsap) {
......
......@@ -465,7 +465,7 @@ void irlan_open_data_tsap(struct irlan_cb *self)
/*notify.flow_indication = irlan_eth_flow_indication;*/
notify.disconnect_indication = irlan_disconnect_indication;
notify.instance = self;
strncpy(notify.name, "IrLAN data", NOTIFY_MAX_NAME);
strlcpy(notify.name, "IrLAN data", sizeof(notify.name));
tsap = irttp_open_tsap(LSAP_ANY, DEFAULT_INITIAL_CREDIT, &notify);
if (!tsap) {
......
......@@ -396,7 +396,7 @@ int irlan_provider_open_ctrl_tsap(struct irlan_cb *self)
notify.connect_indication = irlan_provider_connect_indication;
notify.disconnect_indication = irlan_provider_disconnect_indication;
notify.instance = self;
strncpy(notify.name, "IrLAN ctrl (p)", 16);
strlcpy(notify.name, "IrLAN ctrl (p)", sizeof(notify.name));
tsap = irttp_open_tsap(LSAP_ANY, 1, &notify);
if (!tsap) {
......
......@@ -122,8 +122,7 @@ struct irlap_cb *irlap_open(struct net_device *dev, struct qos_info *qos,
self->qos_dev = qos;
/* Copy hardware name */
if(hw_name != NULL) {
strncpy(self->hw_name, hw_name, 2*IFNAMSIZ);
self->hw_name[2*IFNAMSIZ] = '\0';
strlcpy(self->hw_name, hw_name, sizeof(self->hw_name));
} else {
self->hw_name[0] = '\0';
}
......
......@@ -114,7 +114,7 @@ irnet_open_tsap(irnet_socket * self)
notify.flow_indication = irnet_flow_indication;
notify.status_indication = irnet_status_indication;
notify.instance = self;
strncpy(notify.name, IRNET_NOTIFY_NAME, NOTIFY_MAX_NAME);
strlcpy(notify.name, IRNET_NOTIFY_NAME, sizeof(notify.name));
/* Open an IrTTP instance */
self->tsap = irttp_open_tsap(LSAP_ANY, DEFAULT_INITIAL_CREDIT,
......@@ -692,7 +692,7 @@ irnet_daddr_to_dname(irnet_socket * self)
if(discoveries[i].daddr == self->daddr)
{
/* Yes !!! Get it.. */
strncpy(self->rname, discoveries[i].info, NICKNAME_MAX_LEN);
strlcpy(self->rname, discoveries[i].info, sizeof(self->rname));
self->rname[NICKNAME_MAX_LEN + 1] = '\0';
DEBUG(IRDA_SERV_INFO, "Device 0x%08x is in fact ``%s''.\n",
self->daddr, self->rname);
......
......@@ -594,7 +594,7 @@ void hashbin_insert(hashbin_t* hashbin, irda_queue_t* entry, long hashv, char* n
*/
entry->q_hash = hashv;
if ( name )
strncpy( entry->q_name, name, 32);
strlcpy( entry->q_name, name, sizeof(entry->q_name));
/*
* Insert new entry first
......
......@@ -250,7 +250,7 @@ void irda_notify_init(notify_t *notify)
notify->flow_indication = NULL;
notify->status_indication = NULL;
notify->instance = NULL;
strncpy(notify->name, "Unknown", NOTIFY_MAX_NAME);
strlcpy(notify->name, "Unknown", sizeof(notify->name));
}
/*
......
......@@ -255,7 +255,7 @@ static int packet_rcv_spkt(struct sk_buff *skb, struct net_device *dev, struct
*/
spkt->spkt_family = dev->type;
strncpy(spkt->spkt_device, dev->name, sizeof(spkt->spkt_device));
strlcpy(spkt->spkt_device, dev->name, sizeof(spkt->spkt_device));
spkt->spkt_protocol = skb->protocol;
/*
......@@ -878,8 +878,7 @@ static int packet_bind_spkt(struct socket *sock, struct sockaddr *uaddr, int add
if(addr_len!=sizeof(struct sockaddr))
return -EINVAL;
strncpy(name,uaddr->sa_data,14);
name[14]=0;
strlcpy(name,uaddr->sa_data,sizeof(name));
dev = dev_get_by_name(name);
if (dev) {
......@@ -1096,7 +1095,7 @@ static int packet_getname_spkt(struct socket *sock, struct sockaddr *uaddr,
uaddr->sa_family = AF_PACKET;
dev = dev_get_by_index(pkt_sk(sk)->ifindex);
if (dev) {
strncpy(uaddr->sa_data, dev->name, 15);
strlcpy(uaddr->sa_data, dev->name, 15);
dev_put(dev);
} else
memset(uaddr->sa_data, 0, 14);
......
......@@ -1408,8 +1408,7 @@ static int wanpipe_bind(struct socket *sock, struct sockaddr *uaddr, int addr_le
/* Bind a socket to a interface name
* This is used by PVC mostly
*/
strncpy(name,sll->sll_device,14);
name[14]=0;
strlcpy(name,sll->sll_device,sizeof(name));
dev = dev_get_by_name(name);
if (dev == NULL){
printk(KERN_INFO "wansock: Failed to get Dev from name: %s,\n",
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment