mirror of
https://github.com/github/codeql.git
synced 2026-05-04 13:15:21 +02:00
Query for detecting Local Android DoS caused by NFE
This commit is contained in:
@@ -0,0 +1,49 @@
|
||||
package com.example.app;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.os.Bundle;
|
||||
|
||||
/** Android activity that tests app crash by NumberFormatException */
|
||||
public class NFEAndroidDoS extends Activity {
|
||||
// BAD - parse string extra to double
|
||||
public void testOnCreate1(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(-1);
|
||||
|
||||
String minPriceStr = getIntent().getStringExtra("priceMin");
|
||||
double minPrice = Double.parseDouble(minPriceStr);
|
||||
}
|
||||
|
||||
// BAD - parse string extra to integer
|
||||
public void testOnCreate2(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(-1);
|
||||
|
||||
String widthStr = getIntent().getStringExtra("width");
|
||||
int width = Integer.parseInt(widthStr);
|
||||
|
||||
String heightStr = getIntent().getStringExtra("height");
|
||||
int height = Integer.parseInt(heightStr);
|
||||
}
|
||||
|
||||
// GOOD - parse int extra to integer
|
||||
public void testOnCreate3(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(-1);
|
||||
|
||||
int width = getIntent().getIntExtra("width", 0);
|
||||
int height = getIntent().getIntExtra("height", 0);
|
||||
}
|
||||
|
||||
// BAD - convert string extra to double
|
||||
public void testOnCreate4(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(-1);
|
||||
|
||||
String minPriceStr = getIntent().getStringExtra("priceMin");
|
||||
double minPrice = new Double(minPriceStr);
|
||||
|
||||
String maxPriceStr = getIntent().getStringExtra("priceMax");
|
||||
double maxPrice = Double.valueOf(minPriceStr);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user