Skip to content

Commit aadd1b2

Browse files
squeek502andrewrk
authored andcommitted
ChildProcess: fix false positives in windowsCreateProcessSupportsExtension
Previously, the implementation would essentially check `startsWith` instead of `eql` (e.g. it would return true for `.exec` because it erroneously 'matched' `.exe`). Follow up to #13993
1 parent 58c1d98 commit aadd1b2

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

lib/std/child_process.zig

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1357,6 +1357,7 @@ fn windowsCreateProcess(app_name: [*:0]u16, cmd_line: [*:0]u16, envp_ptr: ?[*]u1
13571357

13581358
/// Case-insenstive UTF-16 lookup
13591359
fn windowsCreateProcessSupportsExtension(ext: []const u16) bool {
1360+
if (ext.len != 4) return false;
13601361
const State = enum {
13611362
start,
13621363
dot,
@@ -1413,6 +1414,11 @@ fn windowsCreateProcessSupportsExtension(ext: []const u16) bool {
14131414
return false;
14141415
}
14151416

1417+
test "windowsCreateProcessSupportsExtension" {
1418+
try std.testing.expect(windowsCreateProcessSupportsExtension(&[_]u16{ '.', 'e', 'X', 'e' }));
1419+
try std.testing.expect(!windowsCreateProcessSupportsExtension(&[_]u16{ '.', 'e', 'X', 'e', 'c' }));
1420+
}
1421+
14161422
/// Caller must dealloc.
14171423
fn windowsCreateCommandLine(allocator: mem.Allocator, argv: []const []const u8) ![:0]u8 {
14181424
var buf = std.ArrayList(u8).init(allocator);

0 commit comments

Comments
 (0)