From owner-svn-soc-all@freebsd.org Mon Jun 11 18:08:44 2018 Return-Path: Delivered-To: svn-soc-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id A04D4100167F for ; Mon, 11 Jun 2018 18:08:44 +0000 (UTC) (envelope-from sduo@FreeBSD.org) Received: from mxrelay.ysv.freebsd.org (mxrelay.ysv.freebsd.org [IPv6:2001:1900:2254:206a::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.ysv.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 41060741CE for ; Mon, 11 Jun 2018 18:08:44 +0000 (UTC) (envelope-from sduo@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.ysv.freebsd.org (Postfix) with ESMTPS id 852D3C332 for ; Mon, 11 Jun 2018 18:08:43 +0000 (UTC) (envelope-from sduo@FreeBSD.org) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.15.2/8.15.2) with ESMTP id w5BI8hVr024060 for ; Mon, 11 Jun 2018 18:08:43 GMT (envelope-from sduo@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.15.2/8.15.2/Submit) id w5BI8gpU023073 for svn-soc-all@FreeBSD.org; Mon, 11 Jun 2018 18:08:42 GMT (envelope-from sduo@FreeBSD.org) Date: Mon, 11 Jun 2018 18:08:42 GMT Message-Id: <201806111808.w5BI8gpU023073@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to sduo@FreeBSD.org using -f From: sduo@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r337261 - soc2018/sduo/head/sys/dev/vale_vlan MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 11 Jun 2018 18:08:44 -0000 Author: sduo Date: Mon Jun 11 18:08:40 2018 New Revision: 337261 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=337261 Log: use strncmp() instead of strcmp() Modified: soc2018/sduo/head/sys/dev/vale_vlan/vale_vlan.c Modified: soc2018/sduo/head/sys/dev/vale_vlan/vale_vlan.c ============================================================================== --- soc2018/sduo/head/sys/dev/vale_vlan/vale_vlan.c Tue Jun 5 00:35:49 2018 (r337260) +++ soc2018/sduo/head/sys/dev/vale_vlan/vale_vlan.c Mon Jun 11 18:08:40 2018 (r337261) @@ -335,7 +335,9 @@ } for (i = 0; i < MAX_VLAN_CONFS; ++i) { - if (strcmp(vlan_confs[i].conf_name, conf_name) == 0) { + if (strncmp(vlan_confs[i].conf_name, + conf_name, + sizeof(vlan_confs[i].conf_name)) == 0) { nm_prinf("vale_vlan: a configuration named" "'%s' alredy exists\n", conf_name); return EEXIST; @@ -359,6 +361,8 @@ conf = &vlan_confs[free_conf]; initialize_conf(conf); strncpy(conf->conf_name, conf_name, sizeof(conf->conf_name)); + /* makes sure the string is null-byte ended */ + conf->conf_name[sizeof(conf->conf_name)-1] = '\0'; conf->mod_bdg_auth_token = auth_token; *conf_index = free_conf; @@ -399,7 +403,9 @@ for (i = 0; i < active_vlan_conf; ++i) { int index = vlan_conf_index[i]; - if (strcmp(vlan_confs[index].conf_name, conf_name) == 0) { + if (strncmp(vlan_confs[index].conf_name, + conf_name, + sizeof(vlan_confs[index].conf_name)) == 0) { *conf_index = index; nm_prinf("vale_vlan: successfully selected " "configuration '%s'\n", conf_name); @@ -429,7 +435,9 @@ for (i = 0; i < active_vlan_conf; ++i) { int index = vlan_conf_index[i]; - if (strcmp(vlan_confs[index].conf_name, conf_name) == 0) { + if (strncmp(vlan_confs[index].conf_name, + conf_name, + sizeof(vlan_confs[index].conf_name)) == 0) { conf = &vlan_confs[index]; conf_index = i; break; @@ -538,6 +546,7 @@ hdr.nr_version = NM_API_VERSION; hdr.nr_reqtype = NETMAP_REQ_VALE_NEWIF; strncpy(hdr.nr_name, name, sizeof(hdr.nr_name)); + hdr.nr_name[sizeof(hdr.nr_name)-1] = '\0'; bzero(&newif, sizeof(newif)); hdr.nr_body = (uint64_t)&newif; @@ -602,7 +611,9 @@ struct port_elem *next = NULL; vv_list_foreach_safe(cursor, &conf->port_list, list, next) { - if (strcmp(cursor->port_desc.port_name, port_name) == 0) { + if (strncmp(cursor->port_desc.port_name, + port_name) == 0 + sizeof(cursor->port_desc.port_name)) { vv_list_remove(cursor, list); vv_free(cursor); return 0;