From 039c51dcdb046fe1d21f101196e6e3e4a851b38c Mon Sep 17 00:00:00 2001 From: Ilya Shipitsin Date: Thu, 3 Aug 2023 11:32:26 +0200 Subject: [PATCH] pppd/options.c: handle malloc failure (#425) Signed-off-by: Ilya Shipitsin --- pppd/options.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/pppd/options.c b/pppd/options.c index 42e39b8..4b3e93e 100644 --- a/pppd/options.c +++ b/pppd/options.c @@ -1842,6 +1842,10 @@ user_setenv(char **argv) /* The name never changes, so allocate it with the structure */ if (uep == NULL) { uep = malloc(sizeof (*uep) + (eqp-arg)); + if (uep == NULL) { + novm("environment variable"); + return 1; + } strncpy(uep->ue_name, arg, eqp-arg); uep->ue_name[eqp-arg] = '\0'; uep->ue_next = NULL; @@ -1911,6 +1915,10 @@ user_unsetenv(char **argv) /* The name never changes, so allocate it with the structure */ if (uep == NULL) { uep = malloc(sizeof (*uep) + strlen(arg)); + if (uep == NULL) { + novm("environment variable"); + return 1; + } strcpy(uep->ue_name, arg); uep->ue_next = NULL; insp = &userenv_list; -- 2.39.2