ladybird/Userland
Luke Wilde a54fdd5212 LibJS: Apply source's byte offset in TA#set when both TAs have same type
On the code path where we are setting a TypedArray from another
TypedArray of the same type, we forgo the spec text and simply do a
memmove between the two ArrayBuffers. However, we forgot to apply
source's byte offset on this code path.

This meant if we tried setting a TypedArray from a TypedArray we got
from .subarray(), we would still copy from the start of the subarray's
ArrayBuffer.

This is because .subarray() returns a new TypedArray with the same
ArrayBuffer but the new TypedArray has a smaller length and a byte
offset that the rest of the codebase is responsible for applying.

This affected pako when it was decompressing a zlib stream that has
multiple zlib chunks in it. To read from the second chunk, it would
set the zlib window TypedArray from the .subarray() of the chunk offset
in the stream's TypedArray. This effectively made the decompressed data
from the second chunk a mis-mash of old data that looked completely
scrambled. It would also cause all future decompression using the same
pako Inflate instance to also appear scrambled.

As a pako comment aptly puts it:
> Call updatewindow() to create and/or update the window state.
> Note: a memory error from inflate() is non-recoverable.

This allows us to properly decompress the large compressed payloads
that Discord Gateway sends down to the Discord client. For example,
for an account that's only in the Serenity Discord, one of the payloads
is a 20 KB zlib compressed blob that has two chunks in it.

Surprisingly, this is not covered by test262! I imagine this would have
been caught earlier if there was such a test :^)
2022-03-11 22:20:23 +01:00
..
Applets LibGfx: Rename Color::from_rgba() => Color::from_argb() 2022-03-04 23:40:21 +01:00
Applications Browser: Don't crash when selecting nothing in the Inspector DOM tree 2022-03-11 19:31:59 +01:00
Demos Demos: Create demo for VirGL gpu device 2022-03-09 14:58:48 +03:30
DevTools HackStudio: Add more files to new file menu 2022-03-08 22:42:40 +01:00
DynamicLoader DynamicLoader+LibC+LibTimeZone: Include LibTimeZone sources in LibC 2022-01-23 12:48:26 +00:00
Games LibGfx: Rename Color::from_rgba() => Color::from_argb() 2022-03-04 23:40:21 +01:00
Libraries LibJS: Apply source's byte offset in TA#set when both TAs have same type 2022-03-11 22:20:23 +01:00
Services LibWeb: Move hit testing to the painting tree 2022-03-11 00:21:49 +01:00
Shell Shell: Stop parsing options after the script name 2022-03-11 08:41:21 +03:30
Utilities date: Allow using a custom format string 2022-03-08 23:30:47 +01:00
CMakeLists.txt Tests: Establish root Tests directory, move Userland/Tests there 2021-05-06 17:54:28 +02:00