Skip to content

Conversation

@Xstoudi
Copy link
Contributor

Fixes: #46836

If tests are needed for this, I'll need some guidance about how to do it as I don't know how to test if something produce a segfault or not.

@nodejs-github-botnodejs-github-bot added buffer Issues and PRs related to the buffer subsystem. c++ Issues and PRs that require attention from people who are familiar with C++. needs-ci PRs that need a full CI run. labels May 16, 2023
@XstoudiXstoudiforce-pushed the fix/segfault-hex-encode branch from 1c62637 to ed1b2fdCompareMay 16, 2023 11:53
@XstoudiXstoudi changed the title fix: use size_t instead of uint_32_t to avoid segmentation faultbuffer: use size_t instead of uint_32_t to avoid segmentation faultMay 16, 2023
Copy link
Member

@bnoordhuisbnoordhuis left a comment

Choose a reason for hiding this comment

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

It's spelled uint32_t but LGTM apart from that. :-)

I spotted another bug while looking at the surrounding code: that CHECK(dlen >= slen * 2) a few lines up doesn't guard against overflow. Maybe good for a follow-up PR.

@XstoudiXstoudiforce-pushed the fix/segfault-hex-encode branch from ed1b2fd to 73805bbCompareMay 16, 2023 20:50
@XstoudiXstoudi changed the title buffer: use size_t instead of uint_32_t to avoid segmentation faultbuffer: use size_t instead of uint32_t to avoid segmentation faultMay 16, 2023
@Xstoudi
Copy link
ContributorAuthor

Commit message amended.

I could fix that bug directly if needed but I'm not sure to understand in which case would it let an overflow happen?

@bnoordhuis
Copy link
Member

Imagine size_t is 32 bits and slen == 0x80000001, then slen * 2 wraps around to 2.

As a bug it's mostly hypothetical but it's not entirely in the realm of the impossible.

@bnoordhuisbnoordhuis added request-ci Add this label to start a Jenkins CI on a PR. and removed needs-ci PRs that need a full CI run. labels May 17, 2023
@github-actionsgithub-actionsbot removed the request-ci Add this label to start a Jenkins CI on a PR. label May 17, 2023
@nodejs-github-bot

This comment was marked as outdated.

@nodejs-github-bot

This comment was marked as outdated.

@nodejs-github-bot

This comment was marked as outdated.

@Xstoudi
Copy link
ContributorAuthor

Any chance it get merged?

@targos
Copy link
Member

@nodejs/cpp-reviewers

@aduh95aduh95 added the request-ci Add this label to start a Jenkins CI on a PR. label Aug 10, 2023
@github-actionsgithub-actionsbot removed the request-ci Add this label to start a Jenkins CI on a PR. label Aug 10, 2023
@nodejs-github-bot

This comment was marked as outdated.

@nodejs-github-bot
Copy link
Collaborator

@aduh95aduh95 added the request-ci Add this label to start a Jenkins CI on a PR. label May 10, 2024
@github-actionsgithub-actionsbot removed the request-ci Add this label to start a Jenkins CI on a PR. label May 10, 2024
@nodejs-github-bot
Copy link
Collaborator

@aduh95aduh95force-pushed the fix/segfault-hex-encode branch from e7ba2bf to d80d6caCompareMay 11, 2024 09:16
@nodejs-github-bot
Copy link
Collaborator

@nodejs-github-bot
Copy link
Collaborator

@aduh95aduh95 merged commit 05a941f into nodejs:mainMay 11, 2024
@aduh95
Copy link
Contributor

Landed in 05a941f

targos pushed a commit that referenced this pull request May 11, 2024
Fixes: #46836 PR-URL: #48033 Reviewed-By: Ben Noordhuis <[email protected]> Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Michaël Zasso <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Minwoo Jung <[email protected]> Reviewed-By: Shelley Vohr <[email protected]> Reviewed-By: Stephen Belanger <[email protected]>
@targostargos mentioned this pull request May 13, 2024
marco-ippolito pushed a commit that referenced this pull request Jun 17, 2024
Fixes: #46836 PR-URL: #48033 Reviewed-By: Ben Noordhuis <[email protected]> Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Michaël Zasso <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Minwoo Jung <[email protected]> Reviewed-By: Shelley Vohr <[email protected]> Reviewed-By: Stephen Belanger <[email protected]>
@marco-ippolitomarco-ippolito mentioned this pull request Jun 17, 2024
marco-ippolito pushed a commit that referenced this pull request Jun 17, 2024
Fixes: #46836 PR-URL: #48033 Reviewed-By: Ben Noordhuis <[email protected]> Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Michaël Zasso <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Minwoo Jung <[email protected]> Reviewed-By: Shelley Vohr <[email protected]> Reviewed-By: Stephen Belanger <[email protected]>
marco-ippolito pushed a commit that referenced this pull request Jun 17, 2024
Fixes: #46836 PR-URL: #48033 Reviewed-By: Ben Noordhuis <[email protected]> Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Michaël Zasso <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Minwoo Jung <[email protected]> Reviewed-By: Shelley Vohr <[email protected]> Reviewed-By: Stephen Belanger <[email protected]>
ebouye pushed a commit to ebouye/node that referenced this pull request Jun 20, 2024
Fixes: nodejs#46836 PR-URL: nodejs#48033 Reviewed-By: Ben Noordhuis <[email protected]> Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Michaël Zasso <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Minwoo Jung <[email protected]> Reviewed-By: Shelley Vohr <[email protected]> Reviewed-By: Stephen Belanger <[email protected]>
bmeck pushed a commit to bmeck/node that referenced this pull request Jun 22, 2024
Fixes: nodejs#46836 PR-URL: nodejs#48033 Reviewed-By: Ben Noordhuis <[email protected]> Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Michaël Zasso <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Minwoo Jung <[email protected]> Reviewed-By: Shelley Vohr <[email protected]> Reviewed-By: Stephen Belanger <[email protected]>
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

author readyPRs that have at least one approval, no pending requests for changes, and a CI started.bufferIssues and PRs related to the buffer subsystem.c++Issues and PRs that require attention from people who are familiar with C++.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Integer overflow in StringBytes::Encode hex leads to a crash or an infinite loop

12 participants

@Xstoudi@bnoordhuis@nodejs-github-bot@targos@aduh95@Qard@jasnell@lpinca@codebytere@tniessen@JungMinu@RaisinTen