From c6944765e839e6d22df279c8d7cc02a5afe82050 Mon Sep 17 00:00:00 2001 From: Mikhail Efremov Date: Thu, 25 Dec 2014 17:52:36 +0300 Subject: [PATCH] Check VLAN interface name. --- alterator-net-eth/backend3/net-eth | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/alterator-net-eth/backend3/net-eth b/alterator-net-eth/backend3/net-eth index ed9f8b0..68cb41d 100755 --- a/alterator-net-eth/backend3/net-eth +++ b/alterator-net-eth/backend3/net-eth @@ -1080,6 +1080,18 @@ vlan_edit() { write_iface_option "$cachedir/$new" "VID" "$vid" } +check_vlan() +{ + local name="$1"; shift + + [ -n "$name" ] || return 1 + + if echo "$name" | grep -qs '^[[:alnum:]]$'; then + return 0 + fi + + return 1 +} # ADD NEW VLAN FOR SELECTED INTERFACE vlan_add_new() { @@ -1095,7 +1107,8 @@ vlan_add_new() { return fi - if [ -z "$name" ]; then + if ! check_vlan "$name"; then + write_error "`_ "Invalid VLAN name: $name"`" return fi