Fix off-by-one in expandShortPathNative truncating last path character on Windows#4359
Merged
cklin merged 1 commit intodependabot/npm_and_yarn/extensions/ql-vscode/koffi-2.15.2from Apr 7, 2026
Conversation
Agent-Logs-Url: https://github.com/github/vscode-codeql/sessions/8f55b472-80f3-41e0-8d94-0a7cf66671e4 Co-authored-by: cklin <1418580+cklin@users.noreply.github.com>
Copilot created this pull request from a session on behalf of
cklin
April 7, 2026 18:46
View session
Contributor
There was a problem hiding this comment.
Pull request overview
Fixes a Windows-specific path expansion bug in expandShortPathNative where the last character of the expanded path was being truncated due to an off-by-one error when converting the UTF-16 buffer returned by GetLongPathNameW.
Changes:
- Correct the buffer slice length used when decoding the
GetLongPathNameWresult (length excludes the null terminator, so no- 1is needed).
Show a summary per file
| File | Description |
|---|---|
| extensions/ql-vscode/src/common/short-paths.ts | Fixes UTF-16 buffer decoding length to avoid truncating the last character of expanded Windows paths. |
Copilot's findings
Tip
Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Files reviewed: 1/1 changed files
- Comments generated: 0
a0e327b
into
dependabot/npm_and_yarn/extensions/ql-vscode/koffi-2.15.2
33 checks passed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
GetLongPathNameWreturns the output string length excluding the null terminator, but the buffer slice used(result - 1) * 2, silently dropping the last character of every expanded path (e.g.textfile-with~tilde.txt→textfile-with~tilde.tx).This bug was latent until koffi 2.15.2 fixed its install script (
18467bcc):-p/-dflags in the packagedinstallscript were changed to the correct-P/-D, so the prebuilt native addon is now properly installed andkoffi/indirectloads successfully. In 2.15.1,koffi/indirectfailed to load (caught silently), masking the bug.Fix: