Description: Fix GCC warnings breaking the build
 Adjusts buffer sizes to fit the arguments.
Author: Valentin Vidic <Valentin.Vidic@CARNet.hr>
Last-Update: 2018-07-18
---
This patch header follows DEP-3: http://dep.debian.net/deps/dep3/
--- a/libopenfcoe.c
+++ b/libopenfcoe.c
@@ -72,7 +72,8 @@
 
 	/* Save the path */
 	snprintf(fcf->path, sizeof(fcf->path),
-		 "%s/%s", ctlr->path, dp->d_name);
+		 "%.*s/%s", (int)(sizeof(ctlr->path) - sizeof(dp->d_name) - 1),
+		 ctlr->path, dp->d_name);
 
 	/* Use the index from the logical enumeration */
 	fcf->index = atoi(dp->d_name + sizeof("fcf_") - 1);
@@ -179,7 +180,8 @@
 	if (!rc)
 		goto fail;
 
-	sprintf(hpath, "%s/%s/", SYSFS_FCHOST, fchost);
+	sprintf(hpath, "%s/%.*s/", SYSFS_FCHOST,
+		(int)(sizeof(hpath) - strlen(SYSFS_FCHOST) - 3), fchost);
 
 	rc = sa_sys_read_line(hpath, "symbolic_name", buf, sizeof(buf));
 
@@ -198,7 +200,8 @@
 	sa_sys_read_line(ctlr->path, "mode", buf, sizeof(buf));
 	sa_enum_encode(fip_conn_type_table, buf, &ctlr->mode);
 
-	snprintf(lesb_path, sizeof(lesb_path), "%s/lesb/", ctlr->path);
+	snprintf(lesb_path, sizeof(lesb_path), "%.*s/lesb/",
+		(int)(sizeof(ctlr->path) - sizeof("/lesb/")), ctlr->path);
 
 	/* Get LESB statistics */
 	sa_sys_read_u32(lesb_path, "link_fail",
--- a/fipvlan.c
+++ b/fipvlan.c
@@ -594,7 +594,7 @@
 create_and_start_vlan(struct fcf *fcf, bool vn2vn)
 {
 	struct iff *real_dev, *vlan;
-	char vlan_name[IFNAMSIZ];
+	char vlan_name[MAX_STR_LEN];
 	int rc;
 
 	real_dev = lookup_iff(fcf->ifindex, NULL);
@@ -619,7 +619,7 @@
 				    real_dev->ifname, fcf->vlan, vlan->ifname);
 			rc = 0;
 		} else {
-			snprintf(vlan_name, IFNAMSIZ, "%s.%d%s",
+			snprintf(vlan_name, sizeof(vlan_name), "%s.%d%s",
 				 real_dev->ifname, fcf->vlan, config.suffix);
 			rc = vlan_create(fcf->ifindex, fcf->vlan, vlan_name);
 			if (rc < 0)
--- a/fcoeadm_display.c
+++ b/fcoeadm_display.c
@@ -187,7 +187,7 @@
 	DIR *dir;
 	struct dirent *dp;
 	void (*f)(char *dirname, enum disp_style style);
-	char path[1024];
+	char path[2048];
 
 	f = func;
 
@@ -249,7 +249,7 @@
 	uint64_t lba = 0;
 	uint32_t blksize = 0;
 	char path[1024];
-	char npath[1024];
+	char npath[2048];
 	DIR *dir;
 	struct dirent *dp;
 	struct port_attributes *rport_attrs;
@@ -332,7 +332,7 @@
 	struct dirent *dp;
 	char vendor[256];
 	char path[1024];
-	char npath[1024];
+	char npath[2048];
 	char model[256];
 	char rev[256];
 	DIR *dir;
--- a/fcoemon.c
+++ b/fcoemon.c
@@ -933,7 +933,7 @@
 static struct fcoe_port *fcm_new_vlan(int ifindex, int vid, bool vn2vn)
 {
 	char real_name[IFNAMSIZ];
-	char vlan_name[IFNAMSIZ];
+	char vlan_name[IFNAMSIZ*2];
 	struct fcoe_port *p;
 	static const int flags[] = {
 		[false] = CLIF_FLAGS_FABRIC,
@@ -3528,7 +3528,7 @@
 	}
 
 	cmd = data->cmd;
-	strncpy(ifname, data->ifname, sizeof(data->ifname));
+	strncpy(ifname, data->ifname, sizeof(ifname));
 	ifname[sizeof(data->ifname)] = 0;
 
 	if (cmd != CLIF_PID_CMD) {
