diff mbox

[4/5] net: irda: using strlcpy instead of strncpy

Message ID 1371725385-11540-4-git-send-email-zhaohongjiang@huawei.com
State Rejected, archived
Delegated to: David Miller
Headers show

Commit Message

Zhao Hongjiang June 20, 2013, 10:49 a.m. UTC
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(-)
diff mbox

Patch

diff --git a/net/irda/af_irda.c b/net/irda/af_irda.c
index 0578d4f..f605d23 100644
--- a/net/irda/af_irda.c
+++ b/net/irda/af_irda.c
@@ -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,
 				     &notify);
diff --git a/net/irda/ircomm/ircomm_param.c b/net/irda/ircomm/ircomm_param.c
index 3089391..5b80be8 100644
--- a/net/irda/ircomm/ircomm_param.c
+++ b/net/irda/ircomm/ircomm_param.c
@@ -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;
diff --git a/net/irda/irttp.c b/net/irda/irttp.c
index ae43c62..b6e1c9f 100644
--- a/net/irda/irttp.c
+++ b/net/irda/irttp.c
@@ -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;