improve false positive detection in ufuzz (#3977)
This commit is contained in:
@@ -1182,11 +1182,19 @@ function fuzzy_match(original, uglified) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function patch_try_catch(orig, toplevel) {
|
function patch_try_catch(orig, toplevel) {
|
||||||
var code = orig;
|
var stack = [ {
|
||||||
var tries = [];
|
code: orig,
|
||||||
var offset = 0;
|
index: 0,
|
||||||
|
offset: 0,
|
||||||
|
tries: [],
|
||||||
|
} ];
|
||||||
var re = /(?:(?:^|[\s{}):;])try|}\s*catch\s*\(([^)]+)\)|}\s*finally)\s*(?={)/g;
|
var re = /(?:(?:^|[\s{}):;])try|}\s*catch\s*\(([^)]+)\)|}\s*finally)\s*(?={)/g;
|
||||||
|
while (stack.length) {
|
||||||
|
var code = stack[0].code;
|
||||||
|
var offset = stack[0].offset;
|
||||||
|
var tries = stack[0].tries;
|
||||||
var match;
|
var match;
|
||||||
|
re.lastIndex = stack.shift().index;
|
||||||
while (match = re.exec(code)) {
|
while (match = re.exec(code)) {
|
||||||
var index = match.index + match[0].length + 1;
|
var index = match.index + match[0].length + 1;
|
||||||
if (/(?:^|[\s{}):;])try\s*$/.test(match[0])) {
|
if (/(?:^|[\s{}):;])try\s*$/.test(match[0])) {
|
||||||
@@ -1213,6 +1221,12 @@ function patch_try_catch(orig, toplevel) {
|
|||||||
var new_code = code.slice(0, index) + insert + code.slice(index);
|
var new_code = code.slice(0, index) + insert + code.slice(index);
|
||||||
var result = sandbox.run_code(new_code, toplevel);
|
var result = sandbox.run_code(new_code, toplevel);
|
||||||
if (typeof result != "object" || typeof result.name != "string" || typeof result.message != "string") {
|
if (typeof result != "object" || typeof result.name != "string" || typeof result.message != "string") {
|
||||||
|
if (match[1]) stack.push({
|
||||||
|
code: code,
|
||||||
|
index: index,
|
||||||
|
offset: offset,
|
||||||
|
tries: JSON.parse(JSON.stringify(tries)),
|
||||||
|
});
|
||||||
offset += insert.length;
|
offset += insert.length;
|
||||||
code = new_code;
|
code = new_code;
|
||||||
} else if (result.name == "TypeError" && /'in'/.test(result.message)) {
|
} else if (result.name == "TypeError" && /'in'/.test(result.message)) {
|
||||||
@@ -1223,6 +1237,7 @@ function patch_try_catch(orig, toplevel) {
|
|||||||
return orig.slice(0, index) + 'throw new Error("skipping infinite recursion");' + orig.slice(index);
|
return orig.slice(0, index) + 'throw new Error("skipping infinite recursion");' + orig.slice(index);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var fallback_options = [ JSON.stringify({
|
var fallback_options = [ JSON.stringify({
|
||||||
|
|||||||
Reference in New Issue
Block a user