Skip to content

Reject core cache body ranges where the end precedes the start #1182

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
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
8 changes: 8 additions & 0 deletions runtime/fastly/builtins/cache-core.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -612,6 +612,14 @@ bool CacheEntry::body(JSContext *cx, unsigned argc, JS::Value *vp) {
}
options.end = JS::ToUint64(end);
}

// Reject cases where the start is greater than the end.
// Ideally this would be a host-side check... but we didn't do it there to begin with,
// so we couple it to an SDK/runtime upgrade.
if (!start_val.isUndefined() && !end_val.isUndefined() && options.end > options.start) {
JS_ReportErrorASCII(cx, "end field is before the start field");
return false;
}
}

auto res = handle.get_body(options);
Expand Down
Loading