Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Wiki Markup
The {{open()}} function accepts a third argument to determine a newly created file's access mode. If {{open()}} is used to create a new file and the third argument is omitted, the file may be created with unintended access permissions \[[FIO06-A. Create files with appropriate access permissions]\].

In this non-compliant code example from a vulnerability in the useradd() function of the shadow-utils package CVE-2006-1174 , the third argument to open() has been accidentally ommitted.

Code Block
bgColor#FFCCCC#ffcccc


/* ... */
int fd = open(file_namems, O_CREAT |O_EXCL| O_WRONLY); /* access permissions are missing */
if (fd == -1){
  /* Handle Error */
}
/* ... */|O_TRUNC);

Compliant Solution: (variadic functions)

...