summaryrefslogtreecommitdiff
path: root/iptables.cc
diff options
context:
space:
mode:
authorAaron Kemp <kemp@google.com>2015-03-02 15:05:44 -0500
committerGilad Arnold <garnold@google.com>2015-08-10 23:11:52 -0700
commit1bddb2cfdda68f99d27495a9f6b9f720db2a7144 (patch)
tree90e30706444db84f5dc03ada00b04a0a7aed180b /iptables.cc
parent650d229bfc31be30636c2ac62f242952e4f583d4 (diff)
downloadfirewalld-1bddb2cfdda68f99d27495a9f6b9f720db2a7144.tar.gz
firewalld: allow interface names containing '-'
Previously, interface names could only contain alphanumerics. BUG=none TEST=ran iptables unit tests Change-Id: I19951389f7fef54f74568592f6988fd5da1b164b Reviewed-on: https://chromium-review.googlesource.com/255152 Reviewed-by: Jorge Lucangeli Obes <jorgelo@chromium.org> Tested-by: Aaron Kemp <kemp@google.com> Commit-Queue: Aaron Kemp <kemp@google.com>
Diffstat (limited to 'iptables.cc')
-rw-r--r--iptables.cc11
1 files changed, 8 insertions, 3 deletions
diff --git a/iptables.cc b/iptables.cc
index 43daf1b..73d373d 100644
--- a/iptables.cc
+++ b/iptables.cc
@@ -9,6 +9,7 @@
#include <base/logging.h>
#include <base/strings/string_number_conversions.h>
+#include <base/strings/string_util.h>
#include <base/strings/stringprintf.h>
#include <chromeos/process.h>
@@ -29,13 +30,17 @@ const char kMarkForUserTraffic[] = "1";
const char kTableIdForUserTraffic[] = "1";
bool IsValidInterfaceName(const std::string& iface) {
- // |iface| should be shorter than |kInterfaceNameSize| chars,
- // and have only alphanumeric characters.
+ // |iface| should be shorter than |kInterfaceNameSize| chars and have only
+ // alphanumeric characters (embedded hypens are also permitted).
if (iface.length() >= kInterfaceNameSize) {
return false;
}
+ if (StartsWithASCII(iface, "-", true /* case_sensitive */) ||
+ EndsWith(iface, "-", true /* case_sensitive */)) {
+ return false;
+ }
for (auto c : iface) {
- if (!std::isalnum(c)) {
+ if (!std::isalnum(c) && (c != '-')) {
return false;
}
}