[vm/io] Range check Filter_Process arguments

Add a check both in the native implementation and on the Dart side (to
avoid throwing uncatchable ApiError).

Simplify native implementation: Dart_ListGetAsBytes has fast path for
byte sized typed data lists, so there is no reason to inline the 
same fast path into the caller.

Reported by Kyounghwan Kim (@drg2533)

TEST=runtime/tests/vm/dart/regress_b508627933_test.dart

Bug: b/508627933
Change-Id: I14c0f5270f143ed2386200241b13313f6a6a6964
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/500461
Commit-Queue: Slava Egorov <vegorov@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
This commit is contained in:
Slava Egorov
2026-05-07 04:18:06 -07:00
committed by dart-scoped@luci-project-accounts.iam.gserviceaccount.com
parent 0f9ce46c6d
commit d2903a568c
3 changed files with 54 additions and 37 deletions
@@ -0,0 +1,29 @@
// Copyright (c) 2026, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
// Check that RawZLibFilter.process validates its arguments.
import 'dart:io';
import 'package:expect/expect.dart';
void main() {
Expect.throwsRangeError(
() => RawZLibFilter.deflateFilter().process([1, 2, 3], -1, 0),
);
Expect.throwsRangeError(
() => RawZLibFilter.deflateFilter().process([1, 2, 3], -2, -1),
);
Expect.throwsRangeError(
() => RawZLibFilter.deflateFilter().process([1, 2, 3], 0, -1),
);
Expect.throwsRangeError(
() => RawZLibFilter.deflateFilter().process([1, 2, 3], 4, 2),
);
Expect.throwsRangeError(
() => RawZLibFilter.deflateFilter().process([1, 2, 3], 2, 4),
);
Expect.throwsRangeError(
() => RawZLibFilter.deflateFilter().process([1, 2, 3], 5, 6),
);
}