Validate commands and arguments.

Bug: 5465176
Change-Id: I9402054c20ea6cae42781c35bfc2ade90aac31ce
This commit is contained in:
Jeff Sharkey
2011-10-14 18:32:24 -07:00
parent 27f58b3e26
commit 92c7838ca3

View File

@@ -207,6 +207,13 @@ final class NativeDaemonConnector implements Runnable, Handler.Callback, Watchdo
*/
private void sendCommandLocked(String command, String argument)
throws NativeDaemonConnectorException {
if (command != null && command.indexOf('\0') >= 0) {
throw new IllegalArgumentException("unexpected command: " + command);
}
if (argument != null && argument.indexOf('\0') >= 0) {
throw new IllegalArgumentException("unexpected argument: " + argument);
}
if (LOCAL_LOGD) Slog.d(TAG, String.format("SND -> {%s} {%s}", command, argument));
if (mOutputStream == null) {
Slog.e(TAG, "No connection to daemon", new IllegalStateException());