...
Non-Compliant Code Example
In this example, the user can specify a locked device or a FIFO filename, causing the program to hang on the call to open().
| Code Block | ||
|---|---|---|
| ||
if (!fgets(filename, sizeof(filename), stdin)) {
/* handle error */
}
if (open(filename, O_WRONLY) == -1) {
/* handle error */
}
/* if filename is a fifo or a locked device the program may now hang in the open call */
|
Compliant Solution (POSIX)
...