...
For OpenBSD and Linux operating systems, any created files will have mode S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH
(0666), as modified by the process's umask value. (see See fopen(3)
.).
Compliant Solution: fopen_s()
(ISO/IEC TR 24731-1)
...
Code Block | ||
---|---|---|
| ||
char *file_name;
int fd;
/* initialize file_name */
fd = open(file_name, O_CREAT | O_WRONLY);
/* access permissions were missing */
if (fd == -1){
/* handle Error */
}
|
...
Code Block | ||
---|---|---|
| ||
char *file_name; int file_access_permissions; /* initialize file_name and file_access_permissions */ int fd = open( file_name, O_CREAT | O_WRONLY, file_access_permissions ); if (fd == -1){ /* handle Error */ } |
...
Wiki Markup |
---|
\[[ISO/IEC 9899:1999|AA. C References#ISO/IEC 9899-1999]\] Section 7.19.5.3, "The {{fopen}} function" \[[Open Group 04|AA. C References#Open Group 04]\] "The {{open}} function," "The {{umask}} function" \[[ISO/IEC TR 24731-1:2007|AA. C References#SO/IEC TR 24731-1-2007]\] Section 6.5.2.1, "The {{fopen_s}} function" \[[Viega 03|AA. C References#Viega 03]\] Section 2.7, "Restricting Access Permissions for New Files on Unix" \[[Dowd 06|AA. C References#Dowd 06]\] Chapter 9, "UNIX 1: Privileges and Files" |
...