Skip to content

Commit 0286569

Browse files
committed
test(workspace): create the descendant on disk; write the grant via cbm_fopen
The Windows half of ws_approve_sensitive_matches_across_separator_styles asserted the sensitive-root hint for <cache>/.ssh/cfg/sub without creating that directory. Containment canonicalizes the candidate, which on Windows opens it (CreateFileW, OPEN_EXISTING), so a missing descendant was reported as outside the allowed root and the assertion failed on the Windows shard. Create it the way its parent is created. The grant file is now written through cbm_fopen, the wrapper every repository or user path goes through, in binary mode. Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>
1 parent 5a04e42 commit 0286569

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

‎tests/test_workspace.c‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -452,7 +452,7 @@ TEST(ws_approve_sensitive_matches_across_separator_styles) {
452452

453453
char grant[2048];
454454
snprintf(grant, sizeof(grant), "!%s\\.ssh\\cfg\n", cache);
455-
FILE *f = fopen(path, "w");
455+
FILE *f = cbm_fopen(path, "wb");
456456
ASSERT_NOT_NULL(f);
457457
(void)fprintf(f, "%s", grant);
458458
(void)fclose(f);
@@ -495,6 +495,10 @@ TEST(ws_approve_sensitive_matches_across_separator_styles) {
495495
*p = '/';
496496
}
497497
}
498+
/* Containment canonicalizes the candidate, which on Windows opens it
499+
* (CreateFileW, OPEN_EXISTING): a descendant that is not on disk is
500+
* "outside the allowed root" instead of reaching the sensitive hint. */
501+
ASSERT_TRUE(cbm_mkdir_p(descendant, 0700));
498502
err[0] = '\0';
499503
ASSERT_FALSE(cbm_workspace_root_allowed(descendant, NULL, cache, NULL, err, sizeof(err)));
500504
ASSERT_TRUE(strstr(err, "--approve-sensitive") != NULL);

0 commit comments

Comments
 (0)