mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Summary: See https://github.com/facebook/react-native/issues/35959 . Potentially fixes other issues including https://github.com/facebook/react-native/issues/34988 ## Changelog [INTERNAL] [FIXED] - Blob#slice end check avoids overflow Pull Request resolved: https://github.com/facebook/react-native/pull/35971 Test Plan: Added a test which fails against current release but passes after code changes. Reviewed By: cipolleschi Differential Revision: D42772352 Pulled By: jacdebug fbshipit-source-id: 3c26baedad5cd459061459a9485ae20af1d2417b
This commit is contained in:
committed by
Facebook GitHub Bot
parent
d30bd1bb21
commit
eaf465d0df
@@ -98,6 +98,10 @@ class Blob {
|
||||
// $FlowFixMe[reassign-const]
|
||||
end = this.size + end;
|
||||
}
|
||||
if (end > this.size) {
|
||||
// $FlowFixMe[reassign-const]
|
||||
end = this.size;
|
||||
}
|
||||
size = end - start;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -71,6 +71,11 @@ describe('Blob', function () {
|
||||
expect(sliceB.data.offset).toBe(2384);
|
||||
expect(sliceB.size).toBe(7621 - 2384);
|
||||
expect(sliceB.type).toBe('');
|
||||
|
||||
const sliceC = blob.slice(34543, 34569);
|
||||
|
||||
expect(sliceC.data.offset).toBe(34543);
|
||||
expect(sliceC.size).toBe(Math.min(blob.data.size, 34569) - 34543);
|
||||
});
|
||||
|
||||
it('should close a blob', () => {
|
||||
|
||||
Reference in New Issue
Block a user