Skip to contentSkip to conversation

fix cu3088 group write

PATCH Superseded Guillaume Morin 1 participant 2 messages Aug 19, 2003 – Aug 25, 2003

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 fix cu3088 group write

Hi Linus,

The current cu3088 ccwgroup write code overwrite the last char of the given arguments. This patch fixes the problem :

drivers/s390/net/cu3088.c +2 -2
@@ -64,7 +64,7 @@
 group_write(struct device_driver *drv, const char *buf, size_t count)
 {
 	const char *start, *end;
-	char bus_ids[2][BUS_ID_SIZE], *argv[2];
+	char bus_ids[2][BUS_ID_SIZE+1], *argv[2];
 	int i;
 	int ret;
 	struct ccwgroup_driver *cdrv;
@@ -79,7 +79,7 @@
 
 		if (!(end = strchr(start, delim[i])))
 			return count;
-		len = min_t(ptrdiff_t, BUS_ID_SIZE, end - start);
+		len = min_t(ptrdiff_t, BUS_ID_SIZE, end - start)+1;
 		strlcpy (bus_ids[i], start, len);
 		argv[i] = bus_ids[i];
 		start = end + 1;

memcpy is not an option since the string will be used with strncmp with a length > BUS_ID_SIZE.

Please apply.

Signature · 4 lines
Guillaume Morin <[email protected]>

     Build a man a fire, and he'll be warm for a day.  Set a man on fire,
         and he'll be warm for the rest of his life. (Terry Pratchett)
#1 lore raw

PATCH RESEND 1/1 fix cu3088 group write

Hi Linus, Andrew

The current cu3088 ccwgroup write code overwrite the last char of the given arguments. This following patch fixes the problem. It is been tested and applies on latest bk.

drivers/s390/net/cu3088.c +2 -2
@@ -64,7 +64,7 @@
 group_write(struct device_driver *drv, const char *buf, size_t count)
 {
 	const char *start, *end;
-	char bus_ids[2][BUS_ID_SIZE], *argv[2];
+	char bus_ids[2][BUS_ID_SIZE+1], *argv[2];
 	int i;
 	int ret;
 	struct ccwgroup_driver *cdrv;
@@ -79,7 +79,7 @@
 
 		if (!(end = strchr(start, delim[i])))
 			return count;
-		len = min_t(ptrdiff_t, BUS_ID_SIZE, end - start);
+		len = min_t(ptrdiff_t, BUS_ID_SIZE, end - start)+1;
 		strlcpy (bus_ids[i], start, len);
 		argv[i] = bus_ids[i];
 		start = end + 1;

memcpy is not an option since the string will be used with strncmp with a length > BUS_ID_SIZE.

Please apply.

Signature · 4 lines
Guillaume Morin <[email protected]>

     Build a man a fire, and he'll be warm for a day.  Set a man on fire,
         and he'll be warm for the rest of his life. (Terry Pratchett)