From 968f7c8d772e704ff96bd2923d474c7f969c7c6b Mon Sep 17 00:00:00 2001 From: Ben Pfaff Date: Tue, 27 Apr 2010 10:45:28 -0700 Subject: [PATCH] datapath: Check device name length more carefully in create_dp(). 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. --- datapath/datapath.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/datapath/datapath.c b/datapath/datapath.c index e9590f75..4f74795e 100644 --- a/datapath/datapath.c +++ b/datapath/datapath.c @@ -202,10 +202,14 @@ static int create_dp(int dp_idx, const char __user *devnamep) 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); } -- 2.30.2