Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cp: should filter mode bits on newly created object #530

Open
jtyler76 opened this issue Nov 25, 2024 · 1 comment
Open

cp: should filter mode bits on newly created object #530

jtyler76 opened this issue Nov 25, 2024 · 1 comment

Comments

@jtyler76
Copy link

In cp, the newly created object (the copy) is created using the mode bits of the source object (

fdout = openat(cfd, catch, O_RDWR|O_CREAT|O_TRUNC, try->st.st_mode);
). The issue is that the mode of the source object may have bits set that are not file permission bits, and POSIX states that the effect of setting such bits in open()/openat() is unspecified (see the POSIX spec page for open()/openat() when it describes O_CREAT).

The mode bits passed to openat() in the aforementioned line should be filtered down to only the file permission bits as listed on the <sys/stat.h> page of the POSIX spec.

@landley
Copy link
Owner

landley commented Nov 26, 2024 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants