From 3cbe33df850f3c69349587019a835458e61f1ea5 Mon Sep 17 00:00:00 2001 From: Ben Pfaff Date: Wed, 3 Feb 2016 14:45:30 -0800 Subject: [PATCH] bridge: Also prohibit \ in bridge names. This is only necessary for Windows but it's no great loss elsewhere. Also, document the restriction on bridge names. Signed-off-by: Ben Pfaff Acked-by: Justin Pettit --- vswitchd/bridge.c | 9 ++++++--- vswitchd/vswitch.xml | 12 +++++++++--- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/vswitchd/bridge.c b/vswitchd/bridge.c index f8afe55b1..f8324a290 100644 --- a/vswitchd/bridge.c +++ b/vswitchd/bridge.c @@ -1,4 +1,4 @@ -/* Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015 Nicira, Inc. +/* Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016 Nicira, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -1695,9 +1695,12 @@ add_del_bridges(const struct ovsrec_open_vswitch *cfg) static struct vlog_rate_limit rl = VLOG_RATE_LIMIT_INIT(1, 5); const struct ovsrec_bridge *br_cfg = cfg->bridges[i]; - if (strchr(br_cfg->name, '/')) { + if (strchr(br_cfg->name, '/') || strchr(br_cfg->name, '\\')) { /* Prevent remote ovsdb-server users from accessing arbitrary - * directories, e.g. consider a bridge named "../../../etc/". */ + * directories, e.g. consider a bridge named "../../../etc/". + * + * Prohibiting "\" is only necessary on Windows but it's no great + * loss elsewhere. */ VLOG_WARN_RL(&rl, "ignoring bridge with invalid name \"%s\"", br_cfg->name); } else if (!shash_add_once(&new_br, br_cfg->name, br_cfg)) { diff --git a/vswitchd/vswitch.xml b/vswitchd/vswitch.xml index ce0dbc109..e7c7e3c78 100644 --- a/vswitchd/vswitch.xml +++ b/vswitchd/vswitch.xml @@ -503,9 +503,15 @@ - Bridge identifier. Should be alphanumeric and no more than about 8 - bytes long. Must be unique among the names of ports, interfaces, and - bridges on a host. +

+ Bridge identifier. Should be alphanumeric and no more than about 8 + bytes long. Must be unique among the names of ports, interfaces, and + bridges on a host. +

+ +

+ Forward and backward slashes are prohibited in bridge names. +

-- 2.20.1