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/NetdConstants.h b/server/NetdConstants.h
index e93347c..9b85d16 100644
--- a/server/NetdConstants.h
+++ b/server/NetdConstants.h
@@ -37,6 +37,7 @@
int execIptablesSilently(IptablesTarget target, ...);
int writeFile(const char *path, const char *value, int size);
int readFile(const char *path, char *buf, int *sizep);
+bool isIfaceName(const char *name);
#define ARRAY_SIZE(a) (sizeof(a) / sizeof(*(a)))