From b6949a24b1a050f4da36a3e1771928c39c975f05 Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Mon, 23 Jul 2018 04:24:16 +0000 Subject: [PATCH] qla2xxx: Fix two potential buffer overflows git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@7436 d57e44dd-8a1f-0410-8b47-8ef2f437770f --- qla2x00t/qla_gs.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/qla2x00t/qla_gs.c b/qla2x00t/qla_gs.c index bec33e319..8c42f849f 100644 --- a/qla2x00t/qla_gs.c +++ b/qla2x00t/qla_gs.c @@ -1365,7 +1365,8 @@ qla2x00_fdmi_rhba(scsi_qla_host_t *vha) /* Model description. */ eiter = (struct ct_fdmi_hba_attr *) (entries + size); eiter->type = cpu_to_be16(FDMI_HBA_MODEL_DESCRIPTION); - strncpy(eiter->a.model_desc, ha->model_desc, 80); + strlcpy(eiter->a.model_desc, ha->model_desc, + sizeof(eiter->a.model_desc)); alen = strlen(eiter->a.model_desc); alen += (alen & 3) ? (4 - (alen & 3)) : 4; eiter->len = cpu_to_be16(4 + alen); @@ -1653,8 +1654,8 @@ qla2x00_fdmi_rpa(scsi_qla_host_t *vha) ct_req->req.rpa.attrs.count = cpu_to_be32(FDMI_PORT_ATTR_COUNT); eiter = (struct ct_fdmi_port_attr *) (entries + size); eiter->type = cpu_to_be16(FDMI_PORT_HOST_NAME); - snprintf(eiter->a.host_name, sizeof(eiter->a.host_name), - "%s", fc_host_system_hostname(vha->host)); + strlcpy(eiter->a.host_name, fc_host_system_hostname(vha->host), + sizeof(eiter->a.host_name)); alen = strlen(eiter->a.host_name); alen += (alen & 3) ? (4 - (alen & 3)) : 4; eiter->len = cpu_to_be16(4 + alen);