You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The MissingCaseFinder searches for possible cases that were not found/there when constructing the initial switch. Now, we insert such a potential case node only if the corresponding case constant does not exist. However, there are cases where we still can insert the missing case.
Consider the following decompiled code (test_switch.ziptest7_b):
A similar example is test18 in the same executable, we currently have:
inttest18() {
intvar_0;
int*var_1;
printf("Enter week number(1-7): ");
var_1=&var_0;
__isoc99_scanf(0x804c025, var_1);
switch(var_0) {
case1:
printf("Monday");
var_0+=0x1f4;
break;
case0x1f4:
printf("Friday");
break;
}
if ((var_0!=1) && (var_0!=12)) {
printf("Invalid input! Please enter week number between 1-7."); // <---------- do not find default do due missing case
}
else {
printf("Tuesday"); // <---------- missing case
}
printf("the number is %d", var_0);
return0;
}
But we would like to have the following output:
inttest18() {
intvar_0;
int*var_1;
printf("Enter week number(1-7): ");
var_1=&var_0;
__isoc99_scanf(0x804c025, var_1);
switch(var_0) {
case1:
printf("Monday");
var_0+=0x1f4;
case12:
printf("Tuesday");
break;
case0x1f4:
printf("Friday");
break;
default:
printf("Invalid input! Please enter week number between 1-7.");
}
printf("the number is %d", var_0);
return0;
}
Remark: test18 also has another problem, see Bug #19
Approach
Find a good way to check whether it is possible to insert a case node whose case constant already exists.
It is important to consider the reachability of the nodes.
The text was updated successfully, but these errors were encountered:
Additionally:
In missing_case_finder.py line 216, two case candidates can have the same constant. At the moment, we add the first that fits. However, this may not be the best solution.
Check for the same constants and merge?
If this is not the case, find the most suitable (easiest in complexity?)
Proposal
The
MissingCaseFinder
searches for possible cases that were not found/there when constructing the initial switch. Now, we insert such a potential case node only if the corresponding case constant does not exist. However, there are cases where we still can insert the missing case.Consider the following decompiled code (test_switch.zip
test7_b
):The preferred output would be:
A similar example is
test18
in the same executable, we currently have:But we would like to have the following output:
Remark:
test18
also has another problem, see Bug #19Approach
Find a good way to check whether it is possible to insert a case node whose case constant already exists.
It is important to consider the reachability of the nodes.
The text was updated successfully, but these errors were encountered: