socsvn commit: r337261 - soc2018/sduo/head/sys/dev/vale_vlan
sduo at FreeBSD.org
sduo at FreeBSD.org
Mon Jun 11 18:08:44 UTC 2018
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;
More information about the svn-soc-all
mailing list