From: Ben Pfaff Date: Tue, 27 Apr 2010 17:45:28 +0000 (-0700) Subject: datapath: Check device name length more carefully in create_dp(). X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=968f7c8d772e704ff96bd2923d474c7f969c7c6b;p=openvswitch 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. --- 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); }