File tree Expand file tree Collapse file tree 1 file changed +19
-1
lines changed Expand file tree Collapse file tree 1 file changed +19
-1
lines changed Original file line number Diff line number Diff line change 4
4
#include <stdint.h>
5
5
#include <android/log.h>
6
6
7
+ /*
8
+ When user loads a third-party ttf font:
9
+ in frameworks/minikin/CmapCoverage.cpp::getCoverageFormat12
10
+ if nGroups >= 0xfffffff0 / kGroupSize, then the ttf font will
11
+ cause continuous rebooting
12
+ */
13
+
7
14
int checkIsVulnerable (){
8
15
FILE * file ;
9
16
long size ;
@@ -14,6 +21,8 @@ int checkIsVulnerable(){
14
21
file = fopen ("/system/lib/libminikin.so" , "rb" );
15
22
16
23
if (file == NULL ){
24
+ // Before 5.0, libminikin didn't exist
25
+ // Hence, not vulnerable
17
26
result = 0 ;
18
27
goto done ;
19
28
}
@@ -25,12 +34,21 @@ int checkIsVulnerable(){
25
34
buffer = (uint8_t * )malloc (sizeof (char )* size );
26
35
27
36
fread (buffer , 1 , size , file );
37
+
38
+ /*
39
+ kGroupSize = 12
40
+ const size_t kMaxNGroups = 0xfffffff0 / kGroupSize ~ 0x15555553 (how it appears in the assembly)
41
+ */
42
+
43
+ // Check if this byte-sequence is in libminikin.so file
28
44
uint8_t needle [4 ] = {0x53 , 0x55 , 0x55 , 0x15 };
29
45
30
46
uint8_t * p = memmem (buffer , size , needle , 4 );
47
+
48
+ // If the byte-sequence is present, that means the bug has been patched
31
49
if (p )
32
50
result = 0 ;
33
- else
51
+ else // Otherwise, there is no check for nGroups <=> vulnerable
34
52
result = 1 ;
35
53
36
54
fclose (file );
You can’t perform that action at this time.
0 commit comments