summaryrefslogtreecommitdiff
path: root/src/shared
diff options
context:
space:
mode:
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2017-02-19 13:52:18 -0500
committerSven Eden <yamakuzure@gmx.net>2017-07-17 17:58:36 +0200
commit75f87c0c51997508efc2c5a08049aa5952b39fee (patch)
tree10600557cb1263550e85146532ac524f90cbc2fa /src/shared
parentf69009b9ced2d38cf8a067c23c77b7bf000afb63 (diff)
shared/pager: abort if we cannot set environment variables
This most likely means oom, it's better to exit than to run less with incomplete settings. CID #714383.
Diffstat (limited to 'src/shared')
-rw-r--r--src/shared/pager.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/src/shared/pager.c b/src/shared/pager.c
index 82f929416..a085a57e3 100644
--- a/src/shared/pager.c
+++ b/src/shared/pager.c
@@ -104,7 +104,8 @@ int pager_open(bool no_pager, bool jump_to_end) {
less_opts = "FRSXMK";
if (jump_to_end)
less_opts = strjoina(less_opts, " +G");
- setenv("LESS", less_opts, 1);
+ if (setenv("LESS", less_opts, 1) < 0)
+ _exit(EXIT_FAILURE);
/* Initialize a good charset for less. This is
* particularly important if we output UTF-8
@@ -112,8 +113,9 @@ int pager_open(bool no_pager, bool jump_to_end) {
less_charset = getenv("SYSTEMD_LESSCHARSET");
if (!less_charset && is_locale_utf8())
less_charset = "utf-8";
- if (less_charset)
- setenv("LESSCHARSET", less_charset, 1);
+ if (less_charset &&
+ setenv("LESSCHARSET", less_charset, 1) < 0)
+ _exit(EXIT_FAILURE);
/* Make sure the pager goes away when the parent dies */
if (prctl(PR_SET_PDEATHSIG, SIGTERM) < 0)