Skip to content

Commit

Permalink
src: do not read string out of bounds
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
zcbenz authored and Medhansh404 committed Jan 19, 2024
1 parent 3430b3f commit 80c11c1
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions src/path.cc
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,14 @@ std::string NormalizeString(const std::string_view path,
int lastSegmentLength = 0;
int lastSlash = -1;
int dots = 0;
char code;
const auto pathLen = path.size();
for (uint8_t i = 0; i <= pathLen; ++i) {
if (i < pathLen) {
char code = 0;
for (size_t i = 0; i <= path.size(); ++i) {
if (i < path.size()) {
code = path[i];
} else if (IsPathSeparator(path[i])) {
} else if (IsPathSeparator(code)) {
break;
} else {
code = node::kPathSeparator;
code = '/';
}

if (IsPathSeparator(code)) {
Expand Down

0 comments on commit 80c11c1

Please sign in to comment.