Skip to contentSkip to conversation

isdn: avoid copying too long drvid

PATCH Superseded Dan Carpenter 2 participants 3 messages Nov 23, 2011 – Nov 29, 2011

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

PATCH 1/1 isdn: avoid copying too long drvid

"cfg->drvid" comes from the user so there is a possibility they didn't NUL terminate properly.

drivers/isdn/i4l/isdn_net.c +2 -0
index 1f73d7f..487d214 100644
@@ -2756,6 +2756,8 @@ isdn_net_setcfg(isdn_net_ioctl_cfg * cfg)
 			char *c,
 			*e;
 
+			if (strlen(cfg->drvid) >= sizeof(drvid))
+				return -EINVAL;
 			drvidx = -1;
 			chidx = -1;
 			strcpy(drvid, cfg->drvid);
#1 lore raw

PATCH v2 1/1 isdn: avoid copying too long drvid

"cfg->drvid" comes from the user so there is a possibility they didn't NUL terminate it properly.

---
v2: use strnlen() instead of strlen().

drivers/isdn/i4l/isdn_net.c +3 -0
index 1f73d7f..2339d73 100644
@@ -2756,6 +2756,9 @@ isdn_net_setcfg(isdn_net_ioctl_cfg * cfg)
 			char *c,
 			*e;
 
+			if (strnlen(cfg->drvid, sizeof(cfg->drvid)) ==
+					sizeof(cfg->drvid))
+				return -EINVAL;
 			drvidx = -1;
 			chidx = -1;
 			strcpy(drvid, cfg->drvid);