andrewrk / andrewrk/libsoundio
mkstemp() in soundio_os_init_mirrored_memory() needs restrictive umask set
- Lingua principale
- C
- Stelle
- 2.1k
- Fork
- 254
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Descrizione
On POSIX systems, `soundio_os_init_mirrored_memory()` calls `mkstemp()` to create a temporary file as a basis for a later `mmap()` call. However, the `mkstemp.3` man page states
```
The old behavior of creating a file with mode 0666 may be a security
risk, especially since other Unix flavors use 0600, and somebody might
overlook this detail when porting programs.
More generally, the POSIX specification of mkstemp() does not say any-
thing about file modes, so the application should make sure its file
mode creation mask (see umask(2)) is set appropriately before calling
mkstemp() (and mkostemp()).
```
This can be addressed by placing something like
```
mode_t old_umask = umask(077);
```
before the call(s), and
```
umask(old_umask);
```
afterward.
(Alternately, might I suggest `tmpfile()` together with `fileno()`? That might be less hassle...)
Guida per i contributori
Nessuna guida per i contributori indicizzata per questo repository
Valutazione
Questa issue non è ancora stata valutata.