Skip to content

Commit f8957a9

Browse files
Reject core cache body ranges where the end precedes the start (#1182)
Co-authored-by: Sy Brand <[email protected]>
1 parent 7d6cf66 commit f8957a9

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

runtime/fastly/builtins/cache-core.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -612,6 +612,14 @@ bool CacheEntry::body(JSContext *cx, unsigned argc, JS::Value *vp) {
612612
}
613613
options.end = JS::ToUint64(end);
614614
}
615+
616+
// Reject cases where the start is greater than the end.
617+
// Ideally this would be a host-side check... but we didn't do it there to begin with,
618+
// so we couple it to an SDK/runtime upgrade.
619+
if (!start_val.isUndefined() && !end_val.isUndefined() && options.end > options.start) {
620+
JS_ReportErrorASCII(cx, "end field is before the start field");
621+
return false;
622+
}
615623
}
616624

617625
auto res = handle.get_body(options);

0 commit comments

Comments
 (0)