server: check interface names in RPC arguments for validity

This patch introduces a method isIfaceName that checks interface
names from various RPCs for validity before e.g. using them as
part of iptables arguments or in filenames.

All of these RPC calls can only be called from applications
with at least the CONNECTIVITY_INTERNAL permission in recent
Android versions, so the impact of the missing checks luckily
isn't very high.

Orig-Author: Jann Horn <jann@thejh.net>

Change-Id: I80df8d745a3de99ad02d6649f0d10562c81f6b98
Signed-off-by: JP Abgrall <jpa@google.com>
diff --git a/server/IdletimerController.cpp b/server/IdletimerController.cpp
index 76b79a7..ae7ae04 100644
--- a/server/IdletimerController.cpp
+++ b/server/IdletimerController.cpp
@@ -192,6 +192,11 @@
   int res;
   char timeout_str[11]; //enough to store any 32-bit unsigned decimal
 
+  if (!isIfaceName(iface)) {
+    errno = ENOENT;
+    return -1;
+  }
+
   snprintf(timeout_str, sizeof(timeout_str), "%u", timeout);
 
   const char *cmd1[] = {