I don't see any value in silently truncating device names. Doing so will
sow confusion in userspace. This commit makes too-long device names
return ENAMETOOLONG.
int i;
if (devnamep) {
- err = -EFAULT;
- if (strncpy_from_user(devname, devnamep, IFNAMSIZ) < 0)
+ int retval = strncpy_from_user(devname, devnamep, IFNAMSIZ);
+ if (retval < 0) {
+ err = -EFAULT;
goto err;
- devname[IFNAMSIZ - 1] = '\0';
+ } else if (retval >= IFNAMSIZ) {
+ err = -ENAMETOOLONG;
+ goto err;
+ }
} else {
snprintf(devname, sizeof devname, "of%d", dp_idx);
}