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

Security: Avoid bad range check pattern #1752

Closed
turnidge opened this issue Feb 17, 2012 · 10 comments
Closed

Security: Avoid bad range check pattern #1752

turnidge opened this issue Feb 17, 2012 · 10 comments
Assignees
Labels
area-vm Use area-vm for VM related issues, including code coverage, and the AOT and JIT backends. type-security

Comments

@turnidge
Copy link
Contributor

The following are two examples of code that uses a bad range check pattern:

  • DART_EXPORT Dart_Handle Dart_ListGetAsBytes(Dart_Handle list,
                                                intptr_t offset,
                                                uint8_t* native_array,
                                                intptr_t length) {
      Isolate* isolate = Isolate::Current();
      DARTSCOPE(isolate);
      const Object& obj = Object::Handle(Api::UnwrapHandle(list));
      if (obj.IsArray()) {
        Array& array_obj = Array::Handle();
        array_obj ^= obj.raw();
        if ((offset + length) <= array_obj.Length()) {
          Object& element = Object::Handle();
  • byte_array.cc:
      static void RangeCheck(const ByteArray& array, const Smi& index,
                           intptr_t num_bytes) {
      if ((index.Value() < 0) || ((index.Value() + num_bytes) > array.Length())) {
@iposva-google
Copy link
Contributor

Added Security label.

@iposva-google
Copy link
Contributor

Set owner to @a-siva.
Added this to the M1 milestone.
Added Accepted label.

@turnidge
Copy link
Contributor Author

Set owner to @turnidge.

@iposva-google
Copy link
Contributor

Removed this from the M1 milestone.
Added this to the M2 milestone.

@iposva-google
Copy link
Contributor

Removed this from the M2 milestone.
Added this to the M3 milestone.

@iposva-google
Copy link
Contributor

Removed this from the M3 milestone.
Added this to the M4 milestone.

@larsbak
Copy link

larsbak commented May 28, 2013

Removed this from the M4 milestone.
Added this to the M5 milestone.

@iposva-google
Copy link
Contributor

Removed Priority-Medium label.
Added Priority-Unassigned label.

@iposva-google
Copy link
Contributor

Removed this from the M5 milestone.

@turnidge turnidge added Type-Defect area-vm Use area-vm for VM related issues, including code coverage, and the AOT and JIT backends. type-security labels Jun 5, 2013
@turnidge turnidge self-assigned this Jun 5, 2013
@iposva-google
Copy link
Contributor

// Perform a range check, checking if
// offset + count <= length
// without the risk of integer overflow.
static inline bool RangeCheck(intptr_t offset,
intptr_t count,
intptr_t length) {
return offset >= 0 &&
count >= 0 &&
length >= 0 &&
count <= (length - offset);
}

copybara-service bot pushed a commit that referenced this issue Nov 7, 2022
… webdev

Revisions updated by `dart tools/rev_sdk_deps.dart`.

crypto (https://github.com/dart-lang/crypto/compare/7cf89d3..e175a95):
  e175a95  2022-11-03  Devon Carew  refactor tests to use a more compact encoding (#134)

dartdoc (https://github.com/dart-lang/dartdoc/compare/179ada0..4b2e01b):
  4b2e01b6  2022-11-03  Sam Rawlins  Deprecate many elements on ModelElement (#3218)
  60cc024a  2022-11-03  Sam Rawlins  Make some logging APIs non-nullable (#3245)
  01c55118  2022-11-03  István Soós  Command-line arguments for limit max file count or total size. (#3231)

file (https://github.com/google/file.dart/compare/b2e31cb..b768f79):
  b768f79  2022-11-07  Devon Carew  add dependabot; run the CI weekly (#203)

intl (https://github.com/dart-lang/intl/compare/dda8ade..442193c):
  442193c  2022-11-07  Fernando Andrade  Fix typo on readme (#506)

shelf (https://github.com/dart-lang/shelf/compare/592656f..5fd2593):
  5fd2593  2022-11-07  Kevin Moore  latest mono_repo
  d1d8dc5  2022-11-07  Kevin Moore  shelf: fix lints (#307)
  64255e5  2022-11-03  Nate Bosch  Prepare to publish shelf_web_socket (#305)

test (https://github.com/dart-lang/test/compare/173a36f..f3fb3ab):
  f3fb3ab6  2022-11-05  stnamco  add lack of description to configuration document (#1782)

test_descriptor (https://github.com/dart-lang/test_descriptor/compare/66f14ce..13dbc20):
  13dbc20  2022-11-07  Kevin Moore  update lints (#45)

webdev (https://github.com/dart-lang/webdev/compare/069b870..47c1c33):
  47c1c33  2022-11-04  Anna Gringauze  Added issue references and removed unused library (#1752)
  542db40  2022-11-04  Anna Gringauze  Update analysis options in dwds (#1777)
  1a36ec8  2022-11-03  Elliott Brooks (she/her)  Send debug info from injected client to the debug extension (#1772)

Change-Id: I65dca831c71fa9487d663cc2a808b78b64424072
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/268360
Auto-Submit: Devon Carew <devoncarew@google.com>
Commit-Queue: Devon Carew <devoncarew@google.com>
Reviewed-by: Kevin Moore <kevmoo@google.com>
Commit-Queue: Kevin Moore <kevmoo@google.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-vm Use area-vm for VM related issues, including code coverage, and the AOT and JIT backends. type-security
Projects
None yet
Development

No branches or pull requests

3 participants