Skip to content

Commit a7a3142

Browse files
Reject core cache body ranges where the end precedes the start
These are rejected in Go as of fastly/compute-sdk-go#165, and in Rust as of PR 5097 in that repository. This is a guest (SDK/runtime) change rather than a host change so as not to break users that may accidentallly rely on this "feature"; hopefully their next SDK upgrade will highlight the issue.
1 parent 7f2a6b7 commit a7a3142

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)