A linux interface is limited to IFNAMSIZ length (16). In case a tap interface is created, add a validity check for it.
Signed-off-by: Eli Britstein <[email protected]> --- lib/netdev-linux.c | 3 +++ tests/system-interface.at | 16 ++++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/lib/netdev-linux.c b/lib/netdev-linux.c index f4d2685a2..e4a70d071 100644 --- a/lib/netdev-linux.c +++ b/lib/netdev-linux.c @@ -962,6 +962,9 @@ netdev_linux_common_construct(struct netdev *netdev_) name); return EINVAL; } + if (strlen(name) >= IFNAMSIZ) { + return ENAMETOOLONG; + } /* The device could be in the same network namespace or in another one. */ netnsid_unset(&netdev->netnsid); diff --git a/tests/system-interface.at b/tests/system-interface.at index 15c4a0e2e..52539848f 100644 --- a/tests/system-interface.at +++ b/tests/system-interface.at @@ -221,3 +221,19 @@ half OVS_TRAFFIC_VSWITCHD_STOP AT_CLEANUP + +AT_SETUP([interface - name too long]) + +OVS_VSWITCHD_START() + +BR_NAME=a234567890b23456 + +AT_CHECK([ + ovs-vsctl add-br $BR_NAME -- \ + set bridge $BR_NAME datapath_type=netdev +], [65], [ignore], [stderr]) + +AT_CHECK([grep 'name too long' stderr], [0], [ignore]) + +OVS_VSWITCHD_STOP(["/could not open network device.*name too long/d"]) +AT_CLEANUP -- 2.34.1 _______________________________________________ dev mailing list [email protected] https://mail.openvswitch.org/mailman/listinfo/ovs-dev
