Skip to content

Commit 4b3bca9

Browse files
committed
Return the correct value when it's vulnerable + add some logging
1 parent 888530d commit 4b3bca9

File tree

3 files changed

+16
-6
lines changed

3 files changed

+16
-6
lines changed

app/src/main/java/fuzion24/device/vulnerability/vulnerabilities/system/CVE20151528.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package fuzion24.device.vulnerability.vulnerabilities.system;
22

33
import android.content.Context;
4+
import android.util.Log;
45

56
import java.util.ArrayList;
67
import java.util.List;
@@ -13,6 +14,8 @@
1314
*/
1415
public class CVE20151528 implements VulnerabilityTest {
1516

17+
private final static String TAG = "CVE-2015-1528";
18+
1619
static {
1720
System.loadLibrary("cve20151528");
1821
}
@@ -33,6 +36,7 @@ public boolean isVulnerable(Context context) throws Exception {
3336
}else if(checkVal == 1) {
3437
return true;
3538
}else {
39+
Log.d(TAG, "Got a return value of " + checkVal);
3640
//TODO: grab more information about failure, errno and error string
3741
throw new Exception("Error running test");
3842
}

app/src/main/jni/Android.mk

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,7 @@ include $(CLEAR_VARS)
174174

175175
LOCAL_MODULE := cve20151528
176176
LOCAL_SRC_FILES := cve20151528.c
177+
LOCAL_LDFLAGS := -llog
177178
LOCAL_C_INCLUDES := $(LOCAL_PATH)/include/
178179

179180
include $(BUILD_SHARED_LIBRARY)
@@ -185,7 +186,7 @@ include $(CLEAR_VARS)
185186
LOCAL_MODULE := cve20151528check
186187
LOCAL_SRC_FILES := cve20151528.c
187188
LOCAL_CFLAGS := -fpie -pie
188-
LOCAL_LDFLAGS := -pie
189+
LOCAL_LDFLAGS := -pie -llog
189190
LOCAL_C_INCLUDES := $(LOCAL_PATH)/include/
190191

191192
include $(BUILD_EXECUTABLE)

app/src/main/jni/cve20151528.c

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@
99

1010
//#include <cutils/native_handle.h>
1111

12+
#define LOG_TAG "CVE_2015_1528"
13+
#define LOG_D(...) do{ __android_log_print( ANDROID_LOG_DEBUG, LOG_TAG, __VA_ARGS__); printf( __VA_ARGS__ ); }while( 0 )
14+
15+
1216
int Check_CVE_2015_1528()
1317
{
1418
const char *libname = "libcutils.so";
@@ -25,10 +29,10 @@ int Check_CVE_2015_1528()
2529
if( !native_handle_create )
2630
{
2731
printf( "missing native_handle_create\n" );
28-
return -1;
32+
return -2;
2933
}
3034

31-
int ret = -1;
35+
int ret = -3;
3236

3337
int numFds = 1025;
3438
int numInts = 1;
@@ -47,15 +51,16 @@ int Check_CVE_2015_1528()
4751
case 12://android wear 5.0.2 LWX49K
4852
if( bla[1] != numFds || bla[2] != numInts )
4953
{
50-
printf( "got back unexpected values\n" );
54+
LOG_D( "got back unexpected values\n" );
5155
}
5256
else
5357
{
54-
printf( "its vulnerable\n" );
58+
LOG_D( "its vulnerable\n" );
59+
return 1;
5560
}
5661
break;
5762
default:
58-
printf( "failed. version %d %d %d\n", bla[0], bla[1], bla[2] );
63+
LOG_D( "failed. version %d %d %d\n", bla[0], bla[1], bla[2] );
5964
break;
6065
}
6166

0 commit comments

Comments
 (0)