-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
open() with O_WRONLY tries to incorrectly access the mode variable. #9998
Comments
Due to the way that NuttX handles the open flags, also |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
As I see here, this is the standard prototype for the
open()
function:According to the standard, the varargs may be parsed as a
mode_t
variable, but only ifO_CREAT
orO_TMPFILE
is specified in the file flags.If neither of the two is specified, then the extra arguments are not needed, and are ignored.
From open group:
From Linux:
However, this is not the case in NuttX.
As I see here, NuttX will try to parse
ap
also in the case ofO_WRONLY
.As far as I understand, even
O_WRONLY
will create the file if it does not exist, but I cannot see this referenced in any of the standards.This is a portability and standards conformance issue.
Code ported from other platforms may use
O_WRONLY
without specifing the mode. In this caseopen()
will read garbage from the stack.The text was updated successfully, but these errors were encountered: