Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
halo
cts
Commits
4aec0ca7
Commit
4aec0ca7
authored
11 years ago
by
Nick Kralevich
Committed by
Android Git Automerger
11 years ago
Browse files
Options
Download
Plain Diff
am
312d6038
: am
a6355635
: Don\'t allow "enable_root" in adb.
* commit '
312d6038
': Don't allow "enable_root" in adb.
parents
bb4f7277
312d6038
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
32 additions
and
0 deletions
+32
-0
tests/tests/security/src/android/security/cts/BannedFilesTest.java
...ts/security/src/android/security/cts/BannedFilesTest.java
+32
-0
No files found.
tests/tests/security/src/android/security/cts/BannedFilesTest.java
View file @
4aec0ca7
...
...
@@ -20,7 +20,11 @@ import android.os.cts.FileUtils;
import
junit.framework.TestCase
;
import
java.io.DataInputStream
;
import
java.io.File
;
import
java.io.FileInputStream
;
import
java.io.IOException
;
import
java.io.UnsupportedEncodingException
;
public
class
BannedFilesTest
extends
TestCase
{
...
...
@@ -48,6 +52,34 @@ public class BannedFilesTest extends TestCase {
}
}
public
void
testNoEnableRoot
()
throws
UnsupportedEncodingException
{
byte
[]
badPattern
=
"enable_root"
.
getBytes
(
"US-ASCII"
);
assertFileDoesNotContain
(
"/system/bin/adb"
,
badPattern
);
}
private
static
void
assertFileDoesNotContain
(
String
filename
,
byte
[]
pattern
)
{
try
{
File
f
=
new
File
(
filename
);
byte
[]
fileData
=
new
byte
[(
int
)
f
.
length
()];
DataInputStream
dis
=
new
DataInputStream
(
new
FileInputStream
(
f
));
dis
.
readFully
(
fileData
);
dis
.
close
();
outer:
for
(
int
i
=
0
;
i
<
(
fileData
.
length
-
pattern
.
length
);
i
++)
{
for
(
int
j
=
0
;
j
<
pattern
.
length
;
j
++)
{
if
(
fileData
[
i
+
j
]
!=
pattern
[
j
])
{
continue
outer
;
}
}
fail
(
"Found banned pattern in "
+
filename
);
}
}
catch
(
IOException
e
)
{
// ignore - no such file, or IO error. Assume OK.
}
}
/**
* setuid or setgid "ip" command can be used to modify the
* routing tables of a device, potentially allowing a malicious
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment