mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-01-04 22:40:16 +01:00
cli: don't use unsafe functions in pager_fallback()
The pager_fallback() runs in the forked child process. As such, it can only use functions from `man signal-safety` or that are explicitly allowed. We are mostly good, but g_printerr() is not allowed. It can deadlock. Just avoid it. It's not very to print those error messages anyway.
This commit is contained in:
parent
a35d8ff769
commit
e843a7caa2
1 changed files with 4 additions and 6 deletions
|
|
@ -1423,20 +1423,18 @@ pager_fallback(void)
|
|||
{
|
||||
char buf[64];
|
||||
int rb;
|
||||
int errsv;
|
||||
|
||||
/* We are still in the child process (after fork() and before exec()).
|
||||
* We must only used functions listed in `man signal-safety`. */
|
||||
|
||||
do {
|
||||
rb = read(STDIN_FILENO, buf, sizeof(buf));
|
||||
if (rb == -1) {
|
||||
errsv = errno;
|
||||
if (errsv == EINTR)
|
||||
if (errno == EINTR)
|
||||
continue;
|
||||
g_printerr(_("Error reading nmcli output: %s\n"), nm_strerror_native(errsv));
|
||||
_exit(EXIT_FAILURE);
|
||||
}
|
||||
if (write(STDOUT_FILENO, buf, rb) == -1) {
|
||||
errsv = errno;
|
||||
g_printerr(_("Error writing nmcli output: %s\n"), nm_strerror_native(errsv));
|
||||
_exit(EXIT_FAILURE);
|
||||
}
|
||||
} while (rb > 0);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue