authorgravatar for squeek502@hotmail.comRyan Liptak <squeek502@hotmail.com> 2022-12-30 22:09:31-08:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2022-12-31 20:51:56-05:00
logaadd1b252e1d912e45cc924a15872d7c3d1f9080
tree0c8c1e368ee73a3c7c7b6d314fd38cd50f060ab4
parent58c1d98c1463210135ab7f405d204b0769525328

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 files changed, 6 insertions(+), 0 deletions(-)

lib/std/child_process.zig+6
......@@ -1357,6 +1357,7 @@ fn windowsCreateProcess(app_name: [*:0]u16, cmd_line: [*:0]u16, envp_ptr: ?[*]u1
13571357
13581358/// Case-insenstive UTF-16 lookup
13591359fn 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
1417test "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.
14171423fn windowsCreateCommandLine(allocator: mem.Allocator, argv: []const []const u8) ![:0]u8 {
14181424 var buf = std.ArrayList(u8).init(allocator);