From 984a60965a0e3cd3253a74c77af916b05381c03d Mon Sep 17 00:00:00 2001 From: Sami Kerola Date: Sun, 7 Aug 2016 07:27:21 +0100 Subject: misc: always check setenv(3) return value At least glibc setenv(3) can fail when system runs out of memory. Signed-off-by: Sami Kerola --- term-utils/agetty.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'term-utils/agetty.c') diff --git a/term-utils/agetty.c b/term-utils/agetty.c index d5dc0182f..d6cec8f20 100644 --- a/term-utils/agetty.c +++ b/term-utils/agetty.c @@ -45,6 +45,7 @@ #include "widechar.h" #include "ttyutils.h" #include "color-names.h" +#include "env.h" #ifdef USE_PLYMOUTH_SUPPORT # include "plymouth-ctrl.h" @@ -1155,7 +1156,8 @@ static void open_tty(char *tty, struct termios *tp, struct options *op) op->term = DEFAULT_STERM; } - setenv("TERM", op->term, 1); + if (setenv("TERM", op->term, 1) != 0) + log_err(_("failed to set the %s environment variable"), "TERM"); } /* Initialize termios settings. */ -- cgit v1.2.3-55-g7522