-
Notifications
You must be signed in to change notification settings - Fork 29.8k
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
src: do not read string out of bounds #51358
Conversation
Can you add a test? |
For out-of-bound reads it is usually detected with memory sanitizer or assertions in C++ standard library, the GN build has all the tools and this was caught when running the tests with GN build of Node. I don't have a good idea how to write a test for this with the toolings in upstream. |
c778390
to
7bc8675
Compare
7bc8675
to
ea42eed
Compare
I have updated this PR so the C++ code is a correct translation of the JS code. I still don't quite understand what the js version of |
Landed in 46bc0ff |
PR-URL: nodejs#51358 Reviewed-By: Yagiz Nizipli <yagiz.nizipli@sentry.io> Reviewed-By: Keyhan Vakil <kvakil@sylph.kvakil.me> Reviewed-By: Jiawen Geng <technicalcute@gmail.com>
PR-URL: nodejs#51358 Reviewed-By: Yagiz Nizipli <yagiz.nizipli@sentry.io> Reviewed-By: Keyhan Vakil <kvakil@sylph.kvakil.me> Reviewed-By: Jiawen Geng <technicalcute@gmail.com>
PR-URL: #51358 Reviewed-By: Yagiz Nizipli <yagiz.nizipli@sentry.io> Reviewed-By: Keyhan Vakil <kvakil@sylph.kvakil.me> Reviewed-By: Jiawen Geng <technicalcute@gmail.com>
PR-URL: #51358 Reviewed-By: Yagiz Nizipli <yagiz.nizipli@sentry.io> Reviewed-By: Keyhan Vakil <kvakil@sylph.kvakil.me> Reviewed-By: Jiawen Geng <technicalcute@gmail.com>
PR-URL: #51358 Reviewed-By: Yagiz Nizipli <yagiz.nizipli@sentry.io> Reviewed-By: Keyhan Vakil <kvakil@sylph.kvakil.me> Reviewed-By: Jiawen Geng <technicalcute@gmail.com>
I'm seeing an assertion from libc++ when compiling Node with GN build:
Which comes from the new C++ version of
NormalizeString
from #50758:There seems to be a few errors:
i
should asize_t
, otherwise it can only parse strings at most 255 characters.path[path.size()]
, which reads out-of-bounds.The origin js function was written in an unusual way which I don't quite understand, so I might be missing something here.
If I'm not missing anything, I suggest a fast track merge since it is a out-of-bounds read bug.