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

fix: premature end large body #805

Merged
merged 12 commits into from
May 12, 2021
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fixup
ronag committed May 12, 2021
commit 4a9160ddbe1b330a0a1dc95651a2ad0a5364249e
2 changes: 1 addition & 1 deletion lib/client.js
Original file line number Diff line number Diff line change
@@ -844,7 +844,7 @@ class Parser {
}
}

if (contentLength && bytesRead !== parseInt(contentLength)) {
if (contentLength && bytesRead !== parseInt(contentLength, 10)) {
util.destroy(socket, new ResponseContentLengthMismatchError())
return -1
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this ignored by istanbul? Can't we reproduce?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think llhttp doesn't actually allow it, i.e. it shouldn't be possible.

Copy link
Member Author

@ronag ronag May 12, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will have to dig into it further. Just to tired right now. Only slept 6 hours in total this week 😞 .

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please take some rest 🙏🏻

2 changes: 1 addition & 1 deletion lib/core/request.js
Original file line number Diff line number Diff line change
@@ -189,7 +189,7 @@ function processHeader (request, key, val) {
key.length === 14 &&
key.toLowerCase() === 'content-length'
) {
request.contentLength = parseInt(val)
request.contentLength = parseInt(val, 10)
if (!Number.isFinite(request.contentLength)) {
throw new InvalidArgumentError('invalid content-length header')
}
2 changes: 1 addition & 1 deletion lib/core/util.js
Original file line number Diff line number Diff line change
@@ -147,7 +147,7 @@ function destroy (stream, err) {
const KEEPALIVE_TIMEOUT_EXPR = /timeout=(\d+)/
function parseKeepAliveTimeout (val) {
const m = val.toString().match(KEEPALIVE_TIMEOUT_EXPR)
return m ? parseInt(m[1]) * 1000 : null
return m ? parseInt(m[1], 10) * 1000 : null
}

function parseHeaders (headers, obj = {}) {