nodejs/node
Vedi su GitHub`Buffer.concat` and `Buffer.copy` silently produce invalid results when the operation involves indices equal or greater than 2^32
Open
#55.422 aperta il 17 ott 2024
bufferconfirmed-bughelp wantedregression
Metriche repository
- Star
- (117.218 star)
- Metriche merge PR
- (Merge medio 18g 17h) (219 PR mergiate in 30 g)
Descrizione
Version
v22.9.0, v23.0.0
Platform
Windows 11 x64
Microsoft Windows NT 10.0.22631.0 x64
Subsystem
Buffer
What steps will reproduce the bug?
const largeBuffer = Buffer.alloc(2 ** 32 + 5)
largeBuffer.fill(111)
const result = Buffer.concat([largeBuffer])
console.log(result)
How often does it reproduce? Is there a required condition?
Consistent in v22.9.0 and v23.0.0
What is the expected behavior? Why is that the expected behavior?
All bytes of the return buffer produced by Buffer.concat([largeBuffer]) should be identical to the source:
In this example:
111, 111, 111, 111, 111, 111, 111, 111, 111, 111, 111, ....
What do you see instead?
In the returned buffer, first 5 bytes are 111, and all following ones are 0.
111, 111, 111, 111, 111, 0, 0, 0, 0, 0, 0, ....
The console.log(result) output looks like:
<Buffer 6f 6f 6f 6f 6f 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ... 4294967251
more bytes>
Additional information
No response