From: Ilya Shipitsin Date: Thu, 3 Aug 2023 09:32:26 +0000 (+0200) Subject: pppd/options.c: handle malloc failure (#425) X-Git-Url: https://git.ozlabs.org/?p=ppp.git;a=commitdiff_plain;h=039c51dcdb046fe1d21f101196e6e3e4a851b38c pppd/options.c: handle malloc failure (#425) Signed-off-by: Ilya Shipitsin --- 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;