Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

src: perform bounds checking on error source line #33645

Closed
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
fixup! src: perform bounds checking on error source line
  • Loading branch information
addaleax committed May 30, 2020
commit e9e7286bf0b2c02ef797ee5847720d1eecfa9e94
4 changes: 2 additions & 2 deletions src/node_errors.cc
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,9 @@ static std::string GetErrorSource(Isolate* isolate,
linenum,
sourceline.c_str());
CHECK_GT(buf.size(), 0);
*added_exception_line = true;

if (start >= end ||
if (start > end ||
start < 0 ||
static_cast<size_t>(end) > sourceline.size()) {
return buf;
Expand All @@ -142,7 +143,6 @@ static std::string GetErrorSource(Isolate* isolate,
CHECK_LE(off, kUnderlineBufsize);
underline_buf[off++] = '\n';

*added_exception_line = true;
return buf + std::string(underline_buf, off);
}

Expand Down