@@ -480,7 +480,7 @@ static int irda_open_tsap(struct irda_sock *self, __u8 tsap_sel, char *name)
notify.udata_indication = irda_data_indication;
notify.flow_indication = irda_flow_indication;
notify.instance = self;
- strncpy(notify.name, name, NOTIFY_MAX_NAME);
+ strlcpy(notify.name, name, sizeof(notify.name));
self->tsap = irttp_open_tsap(tsap_sel, DEFAULT_INITIAL_CREDIT,
¬ify);
@@ -259,7 +259,8 @@ static int ircomm_param_port_name(void *instance, irda_param_t *param, int get)
IRDA_DEBUG(0, "%s(), not imp!\n", __func__ );
} else {
IRDA_DEBUG(0, "%s(), port-name=%s\n", __func__ , param->pv.c);
- strncpy(self->settings.port_name, param->pv.c, 32);
+ strlcpy(self->settings.port_name, param->pv.c,
+ sizeof(self->settings.port_name));
}
return 0;
@@ -430,7 +430,7 @@ struct tsap_cb *irttp_open_tsap(__u8 stsap_sel, int credit, notify_t *notify)
if(notify->status_indication != NULL)
ttp_notify.status_indication = irttp_status_indication;
ttp_notify.instance = self;
- strncpy(ttp_notify.name, notify->name, NOTIFY_MAX_NAME);
+ strlcpy(ttp_notify.name, notify->name, sizeof(ttp_notify.name));
self->magic = TTP_TSAP_MAGIC;
self->connected = FALSE;
for NUL terminated string, need alway set '\0' in the end. Signed-off-by: Zhao Hongjiang <zhaohongjiang@huawei.com> --- net/irda/af_irda.c | 2 +- net/irda/ircomm/ircomm_param.c | 3 ++- net/irda/irttp.c | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-)