Skip to content

Commit

Permalink
Address PowerShell-related fuzz crashes (#463)
Browse files Browse the repository at this point in the history
* Add item to fuzz corpus causing the crash

* Run Windows workflow on fuzz-related changes

* Update fuzz prep for PowerShell

Take carriage return into account when escaping backslashes at the end
of arguments.
  • Loading branch information
ericcornelissen authored Oct 15, 2022
1 parent cc3a816 commit 6c31238
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 2 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/checks-windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@ on:
pull_request:
paths:
- src/win.js
- test/fuzz/**
push:
paths:
- src/win.js
- test/fuzz/**
branches:
- main

Expand Down
4 changes: 2 additions & 2 deletions test/fuzz/_common.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ function getFuzzShell() {
}

/**
* Prepare an argument for echoing to accomodate shell-specific behaviour.
* Prepare an argument for echoing to accommodate shell-specific behaviour.
*
* @param {object} args The function arguments.
* @param {string} args.arg The input argument that will be echoed.
Expand Down Expand Up @@ -138,7 +138,7 @@ function prepareArg({ arg, quoted, shell }, disableExtraWindowsPreparations) {

// ... and interprets arguments with `\"` as `"` (even if there's a null
// character between `\` and `"`) so we escape the `\`.
arg = arg.replace(/(?<!\\)((?:\\\0*)+)(?="|$)/gu, "$1$1");
arg = arg.replace(/(?<!\\)((?:\\\0*)+)(?="|\r?$)/gu, "$1$1");
} else {
// ... interprets arguments with `\"` as `"` (even if there's a null
// character between `\` and `"`) so we escape the `\`, except that the
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
u�0 �\(?\

0 comments on commit 6c31238

Please sign in to comment.