PowerShell / PowerShell/Win32-OpenSSH

Behavior of open is not consistent when flag O_CREAT is supplied and mode is not supplied

Open
#812 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Issue-Bug
Dominant language
No language data
Stars
8.3k
Forks
819
PR merge metrics
No merged PRs in 30d

Description

Code is at fd32.c:
int
w32_open(const char pathname, int flags, ... / arg /)
{
int min_index = fd_table_get_min_index();
struct w32_io
pio;
va_list valist;
u_short mode = 0;

errno = 0;
if (min_index == -1)
	return -1;
if (flags & O_CREAT) {
	va_start(valist, flags);
	mode = va_arg(valist, u_short);
	va_end(valist);
}

...

following test in file_tests.c failed and commented out:
{
//f = open(tmp_filename, O_WRONLY | O_CREAT | O_TRUNC);
//ASSERT_INT_EQ(f, -1);
}

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in fd32.c at w32_open and compare its O_CREAT argument handling with the commented test in file_tests.c. Run the relevant file tests and restore coverage for open(tmp_filename, O_WRONLY | O_CREAT | O_TRUNC) without a mode argument; done means the behavior is consistent and the test passes.

Written by the indexing model from the issue text.

Assessment

Tech stack
c
Domain
operating-systems
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.