Skip to content

Commit b7cd239

Browse files
rhendricGudahtt
authored andcommitted
fix(lockfile): prevent infinite loop
Fix bug where yarn could get into an infinite loop when parsing a corrupted lockfile with an unterminated string.
1 parent 800b266 commit b7cd239

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ Please add one entry in this file for each change in Yarn's behavior. Use the sa
44

55
## Master
66

7+
- Prevent infinite loop when parsing corrupted lockfile with unterminated string
8+
9+
[#4965](https://github.com/yarnpkg/yarn/pull/4965) - [**Ryan Hendrickson**](https://github.com/rhendric)
10+
711
- Environment variables now have to **start** with `YARN_` (instead of just contain it) to be considered
812

913
[#6518](https://github.com/yarnpkg/yarn/pull/6518) - [**Michael Gmelin**](https://blog.grem.de)

src/lockfile/parse.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ function* tokenise(input: string): Iterator<Token> {
9494
}
9595
} else if (input[0] === '"') {
9696
let i = 1;
97-
for (; ; i++) {
97+
for (; i < input.length; i++) {
9898
if (input[i] === '"') {
9999
const isEscaped = input[i - 1] === '\\' && input[i - 2] !== '\\';
100100
if (!isEscaped) {

0 commit comments

Comments
 (0)