websocket: don't use pooled buffer in mask pool#3357
Merged
ronag merged 4 commits intonodejs:mainfrom Jun 23, 2024
Merged
Conversation
tsctx
commented
Jun 22, 2024
| if (bufIdx === BUFFER_SIZE) { | ||
| bufIdx = 0 | ||
| crypto.randomFillSync((buffer ??= Buffer.allocUnsafe(BUFFER_SIZE)), 0, BUFFER_SIZE) | ||
| crypto.randomFillSync((buffer ??= Buffer.allocUnsafeSlow(BUFFER_SIZE)), 0, BUFFER_SIZE) |
Member
Author
There was a problem hiding this comment.
No problem, but with the current code, I have some concerns.
Member
There was a problem hiding this comment.
I don't see them, unless we acess buffer.buffer anywhere
Member
Author
There was a problem hiding this comment.
If they access it, they can rewrite the mask, right?
Member
Author
There was a problem hiding this comment.
example:
import { WebSocket } from './index.js'
Buffer.poolSize = 16386 * 4
// any echo server url
const u = new WebSocket('ws://localhost:3000')
u.onmessage = (data) => {
// The mask can be rewritten here.
new Uint8Array(Buffer.allocUnsafe(1).buffer).fill(0)
u.send('Hi')
}
u.onopen = () => {
u.send('Hi')
}
ronag
approved these changes
Jun 22, 2024
KhafraDev
approved these changes
Jun 22, 2024
Member
KhafraDev
left a comment
There was a problem hiding this comment.
Is it possible to add a test?
Member
Author
|
Unfortunately, I can write a test, but this can't catch using pooled buffer completely. |
Member
|
better something than nothing |
Member
Author
|
test was placed incorrectly. this can catch it until now! |
ronag
approved these changes
Jun 23, 2024
ronag
added a commit
to nxtedition/undici
that referenced
this pull request
Jun 25, 2024
* upstream/main: fix: use explicit flag for when use has interacted with stream (nodejs#3361) refactor: simplify signal handling (nodejs#3362) fix: consider bytes read when dumping (nodejs#3360) websocket: don't use pooled buffer in mask pool (nodejs#3357) Revert "fix: post request signal (nodejs#3354)" (nodejs#3359) fix: post request signal (nodejs#3354) build(deps): bump node from `075a5cc` to `9af472b` in /build (nodejs#3355)
Merged
Closed
Closed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
@mcollina