Bug 1866504 - Reject 0 as minColumn/maxColumn value in the Debugger API query. r=iain

Differential Revision: https://phabricator.services.mozilla.com/D194671
This commit is contained in:
Tooru Fujisawa 2023-11-27 19:05:20 +00:00
parent 5e99ee897f
commit ce8ba5246b
2 changed files with 17 additions and 5 deletions

View file

@ -727,7 +727,15 @@ class DebuggerScript::GetPossibleBreakpointsMatcher {
}
bool parseColumnValue(HandleValue value,
JS::LimitedColumnNumberOneOrigin* result) {
return parseIntValueImpl(value, result->addressOfValueForTranscode());
uint32_t tmp;
if (!parseIntValueImpl(value, &tmp)) {
return false;
}
if (tmp == 0) {
return false;
}
*result->addressOfValueForTranscode() = tmp;
return true;
}
bool parseSizeTValue(HandleValue value, size_t* result) {
return parseIntValueImpl(value, result);
@ -857,7 +865,7 @@ class DebuggerScript::GetPossibleBreakpointsMatcher {
if (!parseColumnValue(minColumnValue, &minColumn)) {
JS_ReportErrorNumberASCII(
cx_, GetErrorMessage, nullptr, JSMSG_UNEXPECTED_TYPE,
"getPossibleBreakpoints' 'minColumn'", "not an integer");
"getPossibleBreakpoints' 'minColumn'", "not a positive integer");
return false;
}
}
@ -883,7 +891,7 @@ class DebuggerScript::GetPossibleBreakpointsMatcher {
if (!parseColumnValue(maxColumnValue, &maxColumn)) {
JS_ReportErrorNumberASCII(
cx_, GetErrorMessage, nullptr, JSMSG_UNEXPECTED_TYPE,
"getPossibleBreakpoints' 'maxColumn'", "not an integer");
"getPossibleBreakpoints' 'maxColumn'", "not a positive integer");
return false;
}
}

View file

@ -41,14 +41,18 @@ function onDebuggerStatement(frame) {
assertBPCount({ minLine: 9, minColumn: 9 }, 1);
assertBPError({ minLine: "1" }, "minLine", "not an integer");
assertBPError({ minColumn: 2 }, "minColumn", "not allowed without 'line' or 'minLine'");
assertBPError({ minLine: 1, minColumn: "2" }, "minColumn", "not an integer");
assertBPError({ minLine: 1, minColumn: "2" }, "minColumn", "not a positive integer");
assertBPError({ minLine: 1, minColumn: 0 }, "minColumn", "not a positive integer");
assertBPError({ minLine: 1, minColumn: -1 }, "minColumn", "not a positive integer");
assertBPCount({ maxLine: 7 }, 5);
assertBPCount({ maxLine: 7, maxColumn: 1 }, 5);
assertBPCount({ maxLine: 7, maxColumn: 9 }, 6);
assertBPError({ maxLine: "1" }, "maxLine", "not an integer");
assertBPError({ maxColumn: 2 }, "maxColumn", "not allowed without 'line' or 'maxLine'");
assertBPError({ maxLine: 1, maxColumn: "2" }, "maxColumn", "not an integer");
assertBPError({ maxLine: 1, maxColumn: "2" }, "maxColumn", "not a positive integer");
assertBPError({ maxLine: 1, maxColumn: 0 }, "maxColumn", "not a positive integer");
assertBPError({ maxLine: 1, maxColumn: -1 }, "maxColumn", "not a positive integer");
assertBPCount({ minLine: 6, maxLine: 8 }, 6);
assertBPCount({ minLine: 6, minColumn: 9, maxLine: 8 }, 5);